Browse the docs

Create organization

POST /v2/api-gateway/organizations

Creates a child organization. When parent_organization_id is omitted the new organization is attached to the caller's top-level organization; when given, the parent must be owned by the caller.

Request

Authentication: your API key in the x-api-key header.

Headers

FieldTypeDescription
Idempotency-KeystringA unique string you choose, up to 255 characters, that makes this request safe to retry. If a request times out or fails in transit, send it again with the same key: the status code and body of the first attempt are returned and the operation is not performed a second time. Stored replies — including failures — are replayed for 24 hours, after which the same key starts a fresh request. Reusing a key for a different request, or sending it while the first request is still running, returns 409. Omit the header and the request behaves exactly as before. Document upload endpoints do not accept it.

Body

FieldTypeDescription
name requiredstringDisplay name of the new organization.
parent_organization_idstring, uuidParent under which to create it. Omit to create a child of your top-level organization.

Example request

cURL

curl --request POST \
     --url 'https://api.themooncard.com/v2/api-gateway/organizations' \
     --header 'x-api-key: YOUR_API_KEY' \
     --header 'content-type: application/json' \
     --data '{
       "name": "string",
       "parent_organization_id": "8d2cd518-5ef2-4280-91e8-63b1a0e672e7"
     }'

Responses

201 Success
FieldTypeDescription
id requiredstringOrganization id.
name requiredstring
parent_organization_id requiredstring, nullableParent organization, or null for a root organization.
created_at requiredstring, nullable
updated_at requiredstring, nullable

JSON

{
  "id": "5c1e2d3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f",
  "name": "Acme Inc.",
  "parent_organization_id": null,
  "created_at": "2026-07-14T11:03:20.000Z",
  "updated_at": "2026-08-16T17:51:01.000Z"
}
400 Error

Validation failed (errors[] lists each offending field) or a domain rule rejected the request ({ message, code }).

The body is the standard error object: see Errors.

401 Error

Missing or invalid credentials, e.g. { "message": "Invalid API Key", "code": "UNAUTHORIZED" }.

The body is the standard error object: see Errors.

404 Error

The caller has no top-level organization (TOP_LEVEL_ORGANIZATION_NOT_FOUND), or parent_organization_id does not exist or is not owned by this organization (ORGANIZATION_NOT_FOUND).

The body is the standard error object: see Errors.

409 Error

The Idempotency-Key you sent is already in use. IDEMPOTENCY_KEY_REUSED — the key was used for a different request; send a new key, or repeat the original request exactly to receive its stored response. IDEMPOTENCY_KEY_IN_PROGRESS — the first request with this key has not finished yet; retry in a few seconds.

The body is the standard error object: see Errors.

500 Error

Unexpected server error. Body is { message: "Internal server error", code: "INTERNAL_SERVER_ERROR" }.

The body is the standard error object: see Errors.

Last updated June 5, 2026