Skip to content
POST/v1/projects/{id}/spaces
Create or get a Space
curl --request POST \
  --url 'https://api.photon.codes/v1/projects/{id}/spaces' \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --header 'idempotency-key: <idempotency-key>' \
  --data-raw '{
  "participantIds": [
    "<string>"
  ],
  "platform": "sms"
}'
{
  "createdAt": "2026-01-01T00:00:00.000Z",
  "details": {},
  "id": "pho_spc_00000000000000000000000001",
  "kind": "direct",
  "metadata": {},
  "participantIds": [
    "pho_usr_00000000000000000000000001",
    "pho_usr_00000000000000000000000002"
  ],
  "platform": "whatsapp",
  "projectId": "pho_prj_00000000000000000000000001",
  "updatedAt": "2026-01-01T00:00:00.000Z"
}

Authorizations

Authorizationstringheaderrequired

Account Service Key, prefixed with pho_ask_, sent as Authorization: Bearer <key>. Acts on behalf of its owning account, subject to the permissions and credential restrictions of each operation. Account access tokens and OAuth grants also use the Bearer header. In organizations that require SSO, Account Service Keys are not accepted for managing the organization's SSO settings, deleting the organization, or checking whether it can be deleted.

Scopes

project:write

Change agent profiles, webhook settings, and other project configuration.

Headers

Photon-Versionenum<string>

Selects the API contract date. Without it, the request is served as 2026-07-01.

Available options: "2026-07-01"
idempotency-keystringrequired

Required for every platform; 1-255 visible ASCII characters. Reuse for retries. For email, the same key and initial participants retrieve the same Space, and a new key starts a separate conversation. SMS identifies its Space by participants, even with a new key. iMessage binds the key to the first participant as creator and the remaining unordered User IDs. Existing matching Spaces are reused.

maxLength: 255
minLength: 1
pattern: "^[\\x21-\\x7e]+$"

Path Parameters

idstringrequired
pattern: "^pho_prj_[0-7][0-9a-hjkmnp-tv-z]{25}$"

Body requiredapplication/json

participantIdsarrayrequired

Canonical Photon User IDs from this project and platform. iMessage uses the first participant as creator when a new chat is needed; remaining order is ignored. Other platforms ignore all participant order. Counts: iMessage 2-1000; both WhatsApp platforms exactly 2; email 1-51; SMS 2-9. Every Space requires a currently project-owned Agent.

uniqueItems: true
Show child attributes
platformenum<string>required
Available options: "sms""email""whatsapp""whatsapp_business""imessage""telegram"
Additional properties are not allowed.

Responseapplication/json

The Space already existed and is returned in its authoritative stored state.

Example: {"createdAt":"2026-01-01T00:00:00.000Z","details":{},"id":"pho_spc_00000000000000000000000001","kind":"direct","metadata":{},"participantIds":["pho_usr_00000000000000000000000001","pho_usr_00000000000000000000000002"],"platform":"whatsapp","projectId":"pho_prj_00000000000000000000000001","updatedAt":"2026-01-01T00:00:00.000Z"}
x-photon-extension: {"discriminator":"platform","fallback":"#/$defs/UnknownSpace","reserved":["sms","whatsapp","whatsapp_business","email","voice","imessage","telegram"]}
createdAtstring<date-time>required

When Photon first persisted this resource.

pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
detailsobjectrequired
Show child attributes
idstringrequired
pattern: "^pho_spc_[0-7][0-9a-hjkmnp-tv-z]{25}$"
kindstringrequired
minLength: 1
metadataobjectrequired
Show child attributes
participantIdsarrayrequired
uniqueItems: true
Show child attributes
platformenum<string>required
const: "sms"
Available options: "sms""email""whatsapp""whatsapp_business""imessage""telegram"
projectIdstringrequired
pattern: "^pho_prj_[0-7][0-9a-hjkmnp-tv-z]{25}$"
updatedAtstring<date-time>required

When Photon last persisted a change to this resource's public state.

pattern: "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
Additional properties are not allowed.

Response Headers

Prevents storage of this create-or-get response.

RFC 9745 structured-field Date at which the operation was or will be deprecated: @ followed by Unix seconds, for example @1767225599.

pattern: "^@-?[0-9]+$"

True when joining or replaying an accepted operation.

Photon-Versionenum<string>

The selected API contract date, also returned on errors after selection.

Available options: "2026-07-01"
RateLimitstring

Current rate-limit state.

Rate-limit policy applied by the gateway.

Delay before retrying, in seconds or as an HTTP date.

Sunsetstring

RFC 8594 HTTP-date (IMF-fixdate) after which the operation may become unavailable, for example Thu, 31 Dec 2026 23:59:59 GMT.

pattern: "^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), [0-9]{2} (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} GMT$"

Identifier for this HTTP attempt.

Trace ID of this request. Sent alongside X-Request-ID when a middleware published a trace ID for the request.

pattern: "^(?!0{32}$)[0-9a-f]{32}$"