Skip to content
Start here

Create a destination address

client.EmailRouting.Addresses.New(ctx, params) (*Address, error)
POST/accounts/{account_id}/email/routing/addresses

Create a destination address to forward your emails to. Destination addresses need to be verified before they can be used.

Security

API Email + API Key

The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

Example:X-Auth-Email: user@example.com

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

Example:X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194
Accepted Permissions (at least one required)
Email Routing Addresses Write
ParametersExpand Collapse
params AddressNewParams
AccountID param.Field[string]

Path param: Identifier.

maxLength32
Email param.Field[string]

Body param: The contact email address of the user.

maxLength90
ReturnsExpand Collapse
type Address struct{…}
ID stringoptional

Destination address identifier.

maxLength32
Created Timeoptional

The date and time the destination address has been created.

formatdate-time
Email stringoptional

The contact email address of the user.

maxLength90
Modified Timeoptional

The date and time the destination address was last modified.

formatdate-time
DeprecatedTag stringoptional

Destination address tag. (Deprecated, replaced by destination address identifier)

maxLength32
Verified Timeoptional

The date and time the destination address has been verified. Null means not verified yet.

formatdate-time

Create a destination address

package main

import (
  "context"
  "fmt"

  "github.com/cloudflare/cloudflare-go"
  "github.com/cloudflare/cloudflare-go/email_routing"
  "github.com/cloudflare/cloudflare-go/option"
)

func main() {
  client := cloudflare.NewClient(
    option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"),
    option.WithAPIEmail("user@example.com"),
  )
  address, err := client.EmailRouting.Addresses.New(context.TODO(), email_routing.AddressNewParams{
    AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"),
    Email: cloudflare.F("user@example.com"),
  })
  if err != nil {
    panic(err.Error())
  }
  fmt.Printf("%+v\n", address.ID)
}
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "ea95132c15732412d22c1476fa83f27a",
    "created": "2014-01-02T02:20:00Z",
    "email": "user@example.com",
    "modified": "2014-01-02T02:20:00Z",
    "tag": "ea95132c15732412d22c1476fa83f27a",
    "verified": "2014-01-02T02:20:00Z"
  }
}
Returns Examples
{
  "errors": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "messages": [
    {
      "code": 1000,
      "message": "message",
      "documentation_url": "documentation_url",
      "source": {
        "pointer": "pointer"
      }
    }
  ],
  "success": true,
  "result": {
    "id": "ea95132c15732412d22c1476fa83f27a",
    "created": "2014-01-02T02:20:00Z",
    "email": "user@example.com",
    "modified": "2014-01-02T02:20:00Z",
    "tag": "ea95132c15732412d22c1476fa83f27a",
    "verified": "2014-01-02T02:20:00Z"
  }
}