Connect email domain
Connect email domain: connectEmailDomain in the TypeScript, Python, Rust and Go clients.
POST /v1/projects/{id}/platforms/email/domains
Reserves a normalized DNS domain and starts its durable email-provider setup. The accepted provision consumes one email-domain entitlement slot until it fails, is cancelled, or becomes a live resource; the plan's email.max_email_domains value sets the project limit. The customer resource does not exist until provider identity and DNS setup reach READY; poll the returned operation for progress. A domain may have only one unfinished provision or live resource globally. Email domains have no additional per-domain charge. The Idempotency-Key is required and permanent: replaying the same key and canonical domain returns the original operation forever. Requires the platforms:write permission bound to the project resource in the path. If the operation fails, its error is the problem of one of these codes: EMAIL_DOMAIN_PROVIDER_REJECTED, EMAIL_DOMAIN_VERIFICATION_FAILED, EMAIL_DOMAIN_VERIFICATION_TIMED_OUT, EMAIL_TENANT_SETUP_TIMED_OUT.
photon.projects.platforms.connectEmailDomain(input: ConnectEmailDomainInput, options?: RequestOptions): Promise<ConnectEmailDomainOutput>photon.projects.platforms.connect_email_domain(input: ConnectEmailDomainInput, *, options: RequestOptions | None = None) -> models.Operationclient.connect_email_domain(idempotency_key: String, id: String, body: &types::ConnectEmailDomainRequest).await -> Result<ResponseValue<types::Operation>, Error<ConnectEmailDomainError>>client.Projects.Platforms.ConnectEmailDomain(ctx context.Context, params *ConnectEmailDomainParams, opts ...RequestOption) (*Operation, error)import { Photon } from "@photon-ai/api";
const photon = new Photon({
headers: { Authorization: `Bearer ${process.env.PHOTON_API_TOKEN}` },
});
const result = await photon.projects.platforms.connectEmailDomain({
path: {
id: "id",
},
headers: {
idempotencyKey: "idempotencyKey",
},
body: {
domain: "domain",
},
});import os
from photon_api import Photon
from photon_api.rpc_generated import ConnectEmailDomainInput
photon = Photon(headers={"Authorization": f"Bearer {os.environ['PHOTON_API_TOKEN']}"})
result = photon.projects.platforms.connect_email_domain(
ConnectEmailDomainInput.model_validate({
"path": {
"id": "id",
},
"headers": {
"Idempotency-Key": "idempotencyKey",
},
"body": {
"domain": "domain",
},
})
)use photon_ai_api::{Credential, PhotonClientBuilder, SecretString};
let token = std::env::var("PHOTON_API_TOKEN")?;
let client = PhotonClientBuilder::new()
.credential("accountServiceKey", Credential::Bearer(SecretString::from(token)))
.build()?;
let result = client
.connect_email_domain(
"idempotencyKey".to_owned(),
"id".to_owned(),
&serde_json::from_value(serde_json::json!({
"domain": "domain",
}))?,
)
.await
.map_err(|error| format!("{error:?}"))?
.into_inner();import (
"context"
"encoding/json"
"os"
photonapi "github.com/photon-hq/api/packages/go"
)
ctx := context.Background()
client := photonapi.NewClient(photonapi.WithAPIKey(os.Getenv("PHOTON_API_TOKEN")))
var body photonapi.ConnectEmailDomainRequest
if err := json.Unmarshal([]byte(`{
"domain": "domain"
}`), &body); err != nil {
return err
}
result, err := client.Projects.Platforms.ConnectEmailDomain(ctx, &photonapi.ConnectEmailDomainParams{
IdempotencyKey: "idempotencyKey",
ID: "id",
Body: body,
})
if err != nil {
return err
}
_ = result{
"cancellable": true,
"createdAt": "2026-01-01T00:00:00.000Z",
"detail": {},
"endedAt": "2026-01-01T00:00:00.000Z",
"error": {
"code": "CHARGE_REFUSED",
"remediation": {
"action": "Check the payment method in Billing, then request the purchase again."
},
"status": 402,
"title": "Charge Refused",
"type": "https://photon.codes/docs/problems/charge-refused"
},
"operationId": "string",
"projectId": "string",
"reason": "charge_refused",
"resourceId": "string",
"resourceType": "string",
"startedAt": "2026-01-01T00:00:00.000Z",
"state": "pending",
"type": "resource.provision",
"updatedAt": "2026-01-01T00:00:00.000Z"
}Parameters
Selects the API contract date. Without it, the request is served as 2026-07-01.
Identifies one logical mutation across retries.
Body
Returns
202 The domain was reserved and setup was dispatched. GET the Location after the Retry-After interval until the operation is terminal. Operation
Headers: Location, Photon-Version. The raw response carries these headers; see Raw responses.
Why the operation failed: the problem of its code, the same object the endpoint returns when it rejects a request, with the status that rejection would have had (the poll itself answers 200). Every code an operation can end with is a branch below, and the endpoint that starts the operation lists its codes. Branch on code, never on status, and keep a default: a code added after your client was generated arrives as a generic problem with type: about:blank and status: 500. That 500 means this document does not describe the code yet, not that the request failed on our side or that retrying will help.