Set the primary email address - Spacefast Docs

Set the primary email address

Points the account at one of its verified addresses and returns every address on the account. Account mail, the Gravatar avatar, and sign-in follow it. The previous primary stays on the account as an ordinary verified address, and both addresses are notified of the change. Requires a recent identity confirmation.

API Endpoint

POST /v1/auth/emails/{emailId}/primary

Authorization

__Host-better-auth.session_token API key · cookierequired

Dashboard session cookie set at sign-in. An operation that lists only this scheme needs a person: API keys and machine credentials are refused. The same session token also works as Authorization: Bearer.

Path parameters

emailId string required

Responses

200 Response for status 200

{
  "$schema": "string<uri>",
  "data": {
    "emails": [
      {
        "id": "string",
        "email": "string",
        "isPrimary": true,
        "verifiedAt": "string",
        "verificationMethod": "email_code"
      }
    ]
  }
}

Error Response

{
  "$schema": "string<uri>",
  "type": "string",
  "title": "string",
  "status": -9007199254740991,
  "detail": "string",
  "code": "string",
  "pointer": "string",
  "details": {
    "property1": null,
    "property2": null
  },
  "suggestions": [
    "string"
  ],
  "next": [
    "string"
  ],
  "requestId": "string"
}

Example Requests

cURL

curl -X POST "https://api.spacefast.com/v1/auth/emails/string/primary" \
  -H "Cookie: __Host-better-auth.session_token=YOUR_API_KEY"

JavaScript

const response = await fetch("https://api.spacefast.com/v1/auth/emails/string/primary", {
  method: "POST",
  headers: {
    "Cookie": "__Host-better-auth.session_token=YOUR_API_KEY"
  }
});

Python

import requests

response = requests.post(
    "https://api.spacefast.com/v1/auth/emails/string/primary",
    headers={
        "Cookie": "__Host-better-auth.session_token=YOUR_API_KEY"
    },
)