CORTEX

Identity & access

Who can call the API and who belongs to the organization: sessions and current identity, user CRUD, service accounts, and API keys.

Common responses

These responses apply across endpoints in this section unless an endpoint documents an additional response.

StatusMeaningBody
200Request succeeded.Endpoint response object.
201Resource created.Created resource object.
400Invalid request.Error envelope.
401Missing or invalid bearer token.Error envelope.
404Resource not found or not visible to the current organization.Error envelope.

Sessions

Mint session

Exchange the calling organization's API key plus a user's email and password for a short-lived bearer JWT that identifies that user. The token expires in 8 hours; client UIs refresh it silently before expiry via POST /v1/auth/sessions/renew (no password needed). Programmatic clients should authenticate with the API key directly rather than minting per-call sessions. A suspended or expired organization mints no session either — same generic `401 invalid_credentials` as a wrong password, so this endpoint never becomes an oracle for the organization's billing/suspension state.

POST/v1/auth/sessions

Request body

NameTypeRequiredDescription
emailstringRequiredThe user's organization email. Case-insensitive on lookup.
passwordstringRequiredThe user's plaintext password (bcrypt-verified server-side).
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/auth/sessions \
  -X POST \
  -H "Authorization: Bearer $CORTEX_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"email":"jane@acme.test","password":"correct-horse-battery-staple"}'

Response codes

StatusMeaningBody
401Missing or invalid credential, wrong password, or a suspended/expired organization (`code: invalid_credentials`).`{ error, code, request_id }`
403Console credentials only (`can_access_console` keys): the authenticated user is a member with no console role, or a role granting zero sections (`code: no_console_role`). The `error` message is user-facing.`{ error, code, request_id }`
422Request body failed validation.`{ error, code, request_id }`
200 OKjson
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIwY2U2NDA5YS0zYmZhLTRlMmYtODgzYS01YTY5NmI0NTFkOGIiLCJvcmciOiJmMWJhMTVlMC1lYmU4LTQxODctYWZlNi0wM2NjYjI1Yjg4MTUiLCJyb2xlIjoiYWRtaW4iLCJhcGlfa2V5X2lkIjoiZmQ1NWNlYTUtNzg5Ny00NzE5LTg4NTItYWM0NGZiYWNjMDc5IiwiaWF0IjoxNzc5MDkyMTE5LCJleHAiOjE3NzkwOTU3MTl9.<sig>",
  "expires_at": "2026-05-18T09:15:19.763Z"
}

Renew session

Exchange a genuine (still-valid or recently-expired) session JWT for a fresh one WITHOUT the user's password. Requires the organization's API key in the Authorization header PLUS the current token in the body — so a stolen browser token alone cannot renew. Used by client UIs to keep users signed in across the 8-hour token lifetime. A token left idle past the 7-day renew window must sign in again; the new token also reflects the user's current role and is rejected if the account has since been suspended — same for the organization: a suspended or expired organization renews nothing.

POST/v1/auth/sessions/renew

Request body

NameTypeRequiredDescription
tokenstringRequiredThe current session JWT to renew. Its signature must be genuine; it may be expired but not older than the 7-day renew window.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/auth/sessions/renew \
  -X POST \
  -H "Authorization: Bearer $CORTEX_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."}'

Response codes

StatusMeaningBody
401Missing API key, invalid/forged token, token past the renew window (`code: renew_window_expired`), or a suspended/expired organization (`code: invalid_credentials`).`{ error, code, request_id }`
403Console credentials only (`can_access_console` keys): the authenticated user is a member with no console role, or a role granting zero sections (`code: no_console_role`). The `error` message is user-facing.`{ error, code, request_id }`
400Request body failed validation (missing token).`{ error, code, request_id }`
200 OKjson
{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.<fresh-claims>.<sig>",
  "expires_at": "2026-05-18T17:15:19.763Z"
}

Get current identity

Return the principal behind the credential on this request. Credential-shaped: every field describes the token (organization, role, principal kind, capability flags), not the user. For user-record fields like email, name, or the per-user is_developer flag, call GET /v1/users/me, which is JWT-only and returns the user row.

GET/v1/auth/identity
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/auth/identity \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
200 OKjson
{
  "credential_type": "session_jwt",
  "user_id": "0ce6409a-3bfa-4e2f-883a-5a696b451d8b",
  "organization_id": "f1ba15e0-ebe8-4187-afe6-03ccb25b8815",
  "role": "admin",
  "api_key_id": "fd55cea5-7897-4719-8852-ac44fbacc079",
  "service_account_id": "8e1b2a30-2c44-4f7e-9a6b-1f3d4c5e6f70",
  "can_mint_cross_org": false,
  "can_access_console": false
}

Get current user

Return the authenticated user's full profile, joined with the user's organization. Requires a session JWT — API-key credentials with no user identity are rejected with 401. Returns id, names, email, role, the per-user is_developer flag, the organization id, name, and is_system flag, and the user's console role (`console_role`, `console_sections` — both null when the user has no console role assigned). Use this endpoint after minting a session to hydrate user-facing UIs (sidebar, account menu, role-gated panels).

GET/v1/users/me
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/users/me \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
200 OKjson
{
  "id": "0ce6409a-3bfa-4e2f-883a-5a696b451d8b",
  "organization_id": "f1ba15e0-ebe8-4187-afe6-03ccb25b8815",
  "organization_name": "Acme",
  "organization_is_system": false,
  "first_name": "Jad",
  "last_name": "Chartouni",
  "display_name": "Jad Chartouni",
  "email": "jad@cognit-dx.com",
  "role": "admin",
  "is_suspended": false,
  "is_developer": true,
  "console_role": "Operator",
  "console_sections": [
    "platform",
    "organizations",
    "sales",
    "operations",
    "ai-platform",
    "billing",
    "access"
  ],
  "created_at": "2026-05-18T10:24:31.000Z",
  "updated_at": "2026-05-18T10:24:31.000Z"
}

Update my profile

Self-service profile update: `firstName`, `lastName`, and `displayName` (at least one required, all trimmed and length-capped). Email and role are directory-managed and rejected here. JWT-only, like the other /me endpoints. Returns the updated user record in the same shape as GET /v1/users/me.

PATCH/v1/users/me

Request body

NameTypeRequiredDescription
firstNamestringOptional1-100 characters.
lastNamestringOptional1-100 characters.
displayNamestringOptional1-150 characters.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/users/me \
  -H "Authorization: Bearer $CORTEX_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
  "firstName": "<firstName>",
  "lastName": "<lastName>",
  "displayName": "<displayName>"
}'

Response codes

StatusMeaningBody
400Empty payload, unknown field, or blank value.`{ error, code, request_id }`
401Missing or invalid credential (or API-key credential without a user).`{ error, code, request_id }`

Change current user password

Change the authenticated user's own password. Requires a session JWT — API-key credentials with no user identity are rejected with 401. The caller must supply their current password; the new password must be at least 12 characters and different from the current one. Session tokens are stateless and not derived from the password, so existing sessions (including other devices) remain valid until they expire.

POST/v1/users/me/password

Request body

NameTypeRequiredDescription
current_passwordstringRequiredThe user's existing password.
new_passwordstringRequiredThe new password. Minimum 12 characters; must differ from the current password.
Example requestbash
curl -X POST https://api.cortex.cognit-dx.com/v1/users/me/password \
  -H "Authorization: Bearer $CORTEX_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"current_password": "old-secret", "new_password": "a-much-longer-secret"}'

Response codes

StatusMeaningBody
204Password updated. No response body.—
400Invalid body, wrong current password, or unchanged password.`{ error, code, request_id }`
401Missing or non-user credential.`{ error, code, request_id }`

Users

Look up users

Minimal org-scoped user directory for share pickers (project members, agent/workflow assignees, and similar UI). Any authenticated org credential can call this — member, admin, or a console-facing API key — since every member is a valid lookup target. Returns only `id`, `display_name`, and `email` per row; role, department, and every other field are withheld so the picker never leaks org structure to callers who shouldn't see it. `search` does a case-insensitive substring match against display name and email. Deleted users are excluded. Results are ordered by display name.

GET/v1/users/lookup

Query parameters

NameTypeRequiredDescription
searchstringOptionalCase-insensitive substring match against display name or email.
limitnumberOptionalMax rows to return, 1 to 50. Defaults to 20.
Example requestbash
curl "https://api.cortex.cognit-dx.com/v1/users/lookup?search=ana" \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
400Invalid `search` or `limit` (e.g. limit over 50).`{ error, code, request_id }`
401Missing or invalid credential.`{ error, code, request_id }`
200 OKjson
{
  "data": [
    {
      "id": "c1d2e3f4-0001-4000-a000-000000000001",
      "display_name": "Amara Osei",
      "email": "amara.osei@acme.example"
    }
  ]
}

List users

List all users in the calling organization. Admin-gated. Results are wrapped in `{ data, has_more, next_cursor }` to match the cursor-pagination envelope used elsewhere in /v1.

GET/v1/users
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/users \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
403Forbidden — caller must be an organization admin.`{ error, code, request_id }`
200 OKjson
{
  "data": [
    {
      "id": "c1d2e3f4-0001-4000-a000-000000000001",
      "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "organization_name": "Acme Corp",
      "organization_is_system": false,
      "first_name": "Amara",
      "last_name": "Osei",
      "display_name": "Amara Osei",
      "email": "amara.osei@acme.example",
      "role": "admin",
      "is_suspended": false,
      "is_developer": false,
      "created_at": "2025-10-01T09:00:00.000Z",
      "updated_at": "2025-10-01T09:00:00.000Z"
    }
  ],
  "has_more": false,
  "next_cursor": null
}

Create user

Create a new user in the calling organization. Admin-gated. Returns the user record and a one-time temporary password that must be changed on first login. The password is shown only in this response and is never persisted in plaintext.

POST/v1/users

Request body

NameTypeRequiredDescription
first_namestringRequiredGiven name. 1–255 characters.
last_namestringRequiredFamily name. 1–255 characters.
display_namestringOptionalDisplay name shown in the UI. Defaults to `first_name + last_name` when omitted.
emailstringRequiredEmail address used for login. Must be unique across the platform.
rolestringOptionalEither `"admin"` or `"member"`. Defaults to `"member"`.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/users \
  -X POST \
  -H "Authorization: Bearer $CORTEX_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"first_name":"Jane","last_name":"Cole","email":"jane@acme.test"}'

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
422Request body failed validation.`{ error, code, request_id }`
403Forbidden — caller must be an organization admin.`{ error, code, request_id }`
409A user with this email already exists.`{ error, code, request_id }`
201 Createdjson
{
  "user": {
    "id": "c1d2e3f4-0001-4000-a000-000000000003",
    "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "first_name": "Sofia",
    "last_name": "Nakamura",
    "display_name": "Sofia Nakamura",
    "email": "sofia.nakamura@acme.example",
    "role": "member",
    "is_suspended": false,
    "created_at": "2026-05-21T10:00:00.000Z",
    "updated_at": "2026-05-21T10:00:00.000Z"
  },
  "password": "Tr0ub4dor&3"
}

Get user

Return a single user by id, scoped to the caller's organization. Admin-gated. Returns 404 for any id that doesn't belong to the caller's org — cross-org probes can't distinguish "doesn't exist" from "exists in another tenant".

GET/v1/users/:userId

Path parameters

NameTypeRequiredDescription
userIdstringRequiredUUID of the user to look up.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/users/0ce6409a-3bfa-4e2f-883a-5a696b451d8b \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404User not found in the caller's organization.`{ error, code, request_id }`
403Forbidden — caller must be an organization admin.`{ error, code, request_id }`
200 OKjson
{
  "id": "c1d2e3f4-0001-4000-a000-000000000002",
  "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "organization_name": "Acme Corp",
  "organization_is_system": false,
  "first_name": "Lucas",
  "last_name": "Ferreira",
  "display_name": "Lucas Ferreira",
  "email": "lucas.ferreira@acme.example",
  "role": "member",
  "is_suspended": false,
  "is_developer": false,
  "created_at": "2025-11-15T14:22:00.000Z",
  "updated_at": "2025-11-15T14:22:00.000Z"
}

Update user

Update a user's name, display name, role, or developer-access flag. All fields optional; strict schema (unknown keys → 400). Admin-gated, and self-modify is forbidden (`self_action_forbidden`) — another admin must perform the action. Cannot demote the last active admin in the org.

PATCH/v1/users/:userId

Path parameters

NameTypeRequiredDescription
userIdstringRequiredUUID of the user to update.

Request body

NameTypeRequiredDescription
first_namestringOptionalGiven name. 1–255 characters.
last_namestringOptionalFamily name. 1–255 characters.
display_namestringOptionalDisplay name shown in the UI.
rolestringOptionalEither `"admin"` or `"member"`.
is_developerbooleanOptionalGrant (`true`) or revoke (`false`) developer access for the target user.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/users/0ce6409a-3bfa-4e2f-883a-5a696b451d8b \
  -X PATCH \
  -H "Authorization: Bearer $CORTEX_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"role":"admin","is_developer":true}'

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404User not found in the caller's organization.`{ error, code, request_id }`
400Request body failed validation.`{ error, code, request_id }`
403Forbidden — caller must be an organization admin, or caller attempted to modify their own user.`{ error, code, request_id }`
409Conflict — cannot demote the last active admin in the organization.`{ error, code, request_id }`
200 OKjson
{
  "id": "c1d2e3f4-0001-4000-a000-000000000002",
  "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "organization_name": "Acme Corp",
  "organization_is_system": false,
  "first_name": "Lucas",
  "last_name": "Ferreira",
  "display_name": "Lucas Ferreira",
  "email": "lucas.ferreira@acme.example",
  "role": "admin",
  "is_suspended": false,
  "is_developer": true,
  "created_at": "2025-11-15T14:22:00.000Z",
  "updated_at": "2026-05-21T10:05:00.000Z"
}

Suspend user

Suspend a user — their credentials are invalidated and they can no longer authenticate. Admin-gated; self-action forbidden. Returns 409 if the target is the last active admin. Returns the updated user record.

POST/v1/users/:userId/suspend

Path parameters

NameTypeRequiredDescription
userIdstringRequiredUUID of the user to suspend.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/users/0ce6409a-3bfa-4e2f-883a-5a696b451d8b/suspend \
  -X POST \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404User not found in the caller's organization.`{ error, code, request_id }`
403Forbidden — caller must be an organization admin, or caller attempted to suspend themselves.`{ error, code, request_id }`
409Conflict — cannot suspend the last active admin in the organization.`{ error, code, request_id }`
200 OKjson
{
  "id": "c1d2e3f4-0001-4000-a000-000000000002",
  "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "organization_name": "Acme Corp",
  "organization_is_system": false,
  "first_name": "Lucas",
  "last_name": "Ferreira",
  "display_name": "Lucas Ferreira",
  "email": "lucas.ferreira@acme.example",
  "role": "member",
  "is_suspended": true,
  "is_developer": false,
  "created_at": "2025-11-15T14:22:00.000Z",
  "updated_at": "2026-05-21T10:10:00.000Z"
}

Unsuspend user

Reverse a prior suspension. The user can authenticate again immediately. Admin-gated; self-action forbidden. Returns the updated user record.

POST/v1/users/:userId/unsuspend

Path parameters

NameTypeRequiredDescription
userIdstringRequiredUUID of the user to unsuspend.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/users/0ce6409a-3bfa-4e2f-883a-5a696b451d8b/unsuspend \
  -X POST \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404User not found in the caller's organization.`{ error, code, request_id }`
403Forbidden — caller must be an organization admin, or caller attempted to unsuspend themselves.`{ error, code, request_id }`
200 OKjson
{
  "id": "c1d2e3f4-0001-4000-a000-000000000002",
  "organization_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "organization_name": "Acme Corp",
  "organization_is_system": false,
  "first_name": "Lucas",
  "last_name": "Ferreira",
  "display_name": "Lucas Ferreira",
  "email": "lucas.ferreira@acme.example",
  "role": "member",
  "is_suspended": false,
  "is_developer": false,
  "created_at": "2025-11-15T14:22:00.000Z",
  "updated_at": "2026-05-21T10:15:00.000Z"
}

Service accounts

List service accounts

List all service accounts in the calling organization. Requires the caller to have `is_developer` access. Results are wrapped in `{ data, has_more }` to match the cursor-pagination envelope used elsewhere in /v1.

GET/v1/service-accounts
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/service-accounts \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
403Developer access required — caller lacks `is_developer = true`.`{ error, code, request_id }`
200 OKjson
{
  "data": [
    {
      "id": "9f7c9d3a-1234-5678-9abc-def012345678",
      "organization_id": "f1ba15e0-ebe8-4187-afe6-03ccb25b8815",
      "name": "deploy-bot",
      "description": "CI/CD pipeline service account.",
      "role": "member",
      "is_suspended": false,
      "created_by_user_id": "0ce6409a-3bfa-4e2f-883a-5a696b451d8b",
      "created_at": "2026-04-01T09:00:00.000Z",
      "updated_at": "2026-05-10T14:00:00.000Z",
      "last_used_at": "2026-05-21T08:30:00.000Z"
    }
  ],
  "has_more": false
}

Create service account

Create a service account in the calling organization. Requires `is_developer` access. The `role` field accepts `member` (default) or `admin`; only an admin caller may set `admin`. Privileged flags (`can_access_console`, `can_mint_cross_org`) are hardcoded `false` on the public API regardless of the request body — only internal seed paths can enable them. Returns 409 if a service account with the same name already exists.

POST/v1/service-accounts

Request body

NameTypeRequiredDescription
namestringRequiredUnique display name within the organization. Trimmed; 1–120 characters.
descriptionstringOptionalOptional free-text description. Maximum 1000 characters.
rolestringOptionalRole granted to API keys issued under this service account. `member` (default) or `admin`. Only an admin caller may set `admin`.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/service-accounts \
  -X POST \
  -H "Authorization: Bearer $CORTEX_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"name":"Sales assistant"}'

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
422Request body failed validation.`{ error, code, request_id }`
403Developer access required — caller lacks `is_developer = true`.`{ error, code, request_id }`
201 Createdjson
{
  "id": "9f7c9d3a-1234-5678-9abc-def012345678",
  "organization_id": "f1ba15e0-ebe8-4187-afe6-03ccb25b8815",
  "name": "deploy-bot",
  "description": "CI/CD pipeline service account.",
  "role": "member",
  "is_suspended": false,
  "created_by_user_id": "0ce6409a-3bfa-4e2f-883a-5a696b451d8b",
  "created_at": "2026-05-21T10:00:00.000Z",
  "updated_at": "2026-05-21T10:00:00.000Z",
  "last_used_at": null
}

Get service account

Return a single service account by ID. Requires `is_developer` access. Returns 404 if the service account does not exist in the calling organization.

GET/v1/service-accounts/:id

Path parameters

NameTypeRequiredDescription
idstringRequiredThe id value from the endpoint path.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/service-accounts/9f7c9d3a-1234-5678-9abc-def012345678 \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404Resource not found in the caller's organization.`{ error, code, request_id }`
403Developer access required — caller lacks `is_developer = true`.`{ error, code, request_id }`
200 OKjson
{
  "id": "9f7c9d3a-1234-5678-9abc-def012345678",
  "organization_id": "f1ba15e0-ebe8-4187-afe6-03ccb25b8815",
  "name": "deploy-bot",
  "description": "CI/CD pipeline service account.",
  "role": "member",
  "is_suspended": false,
  "created_by_user_id": "0ce6409a-3bfa-4e2f-883a-5a696b451d8b",
  "created_at": "2026-04-01T09:00:00.000Z",
  "updated_at": "2026-05-10T14:00:00.000Z",
  "last_used_at": "2026-05-21T08:30:00.000Z"
}

Update service account

Update a service account's name, description, role, or suspension state. All fields optional. A `member` caller cannot elevate a service account to `admin` role (returns 403 forbidden_role). Renaming to a name already taken returns 409. Unknown request fields return 400 (strict schema).

PATCH/v1/service-accounts/:id

Path parameters

NameTypeRequiredDescription
idstringRequiredThe id value from the endpoint path.

Request body

NameTypeRequiredDescription
namestringOptionalNew display name. Trimmed; 1–120 characters. Must be unique in the organization.
descriptionstringOptionalUpdated description. Pass `null` to clear. Maximum 1000 characters.
rolestringOptional`member` or `admin`. Only an admin caller may set `admin`.
is_suspendedbooleanOptionalSet to `true` to suspend the service account (new API keys cannot be issued; existing keys stop working immediately).
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/service-accounts/9f7c9d3a-1234-5678-9abc-def012345678 \
  -X PATCH \
  -H "Authorization: Bearer $CORTEX_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"name":"Sales assistant","description":"Created via the docs example.","role":"member","is_suspended":true}'

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404Resource not found in the caller's organization.`{ error, code, request_id }`
422Request body failed validation.`{ error, code, request_id }`
403Developer access required — caller lacks `is_developer = true`.`{ error, code, request_id }`
200 OKjson
{
  "id": "9f7c9d3a-1234-5678-9abc-def012345678",
  "organization_id": "f1ba15e0-ebe8-4187-afe6-03ccb25b8815",
  "name": "deploy-bot",
  "description": "Updated: handles both CI/CD and staging deploys.",
  "role": "member",
  "is_suspended": false,
  "created_by_user_id": "0ce6409a-3bfa-4e2f-883a-5a696b451d8b",
  "created_at": "2026-04-01T09:00:00.000Z",
  "updated_at": "2026-05-21T11:00:00.000Z",
  "last_used_at": "2026-05-21T08:30:00.000Z"
}

Delete service account

Permanently delete a service account. Returns 409 `has_live_keys` if any non-revoked API keys still belong to it — revoke all keys first. Returns 204 on success.

DELETE/v1/service-accounts/:id

Path parameters

NameTypeRequiredDescription
idstringRequiredThe id value from the endpoint path.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/service-accounts/9f7c9d3a-1234-5678-9abc-def012345678 \
  -X DELETE \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404Resource not found in the caller's organization.`{ error, code, request_id }`
403Developer access required — caller lacks `is_developer = true`.`{ error, code, request_id }`
204 No Contenttext

API keys

List API keys

List all API keys (active and revoked) that belong to this service account. The plaintext key is never returned after initial issuance — only the `prefix` (e.g. `ctxk_live_`) and metadata are included. Results are wrapped in `{ data, has_more }`.

GET/v1/service-accounts/:id/api-keys

Path parameters

NameTypeRequiredDescription
idstringRequiredThe id value from the endpoint path.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/service-accounts/9f7c9d3a-1234-5678-9abc-def012345678/api-keys \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404Resource not found in the caller's organization.`{ error, code, request_id }`
403Developer access required — caller lacks `is_developer = true`.`{ error, code, request_id }`
200 OKjson
{
  "data": [
    {
      "id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
      "prefix": "ctxk_live_",
      "name": "prod-deploy",
      "role": "member",
      "organization_id": "f1ba15e0-ebe8-4187-afe6-03ccb25b8815",
      "service_account_id": "9f7c9d3a-1234-5678-9abc-def012345678",
      "created_by_user_id": "0ce6409a-3bfa-4e2f-883a-5a696b451d8b",
      "created_at": "2026-05-01T10:00:00.000Z",
      "last_used_at": "2026-05-21T08:30:00.000Z",
      "expires_at": null,
      "revoked_at": null
    }
  ],
  "has_more": false
}

Issue API key

Issue a new API key under this service account. The plaintext `key` is returned exactly once in this response — it cannot be recovered later. Store it immediately in your secrets manager. Returns 409 if the service account is suspended. The optional `expires_at` field is an ISO 8601 datetime; omit for a non-expiring key.

POST/v1/service-accounts/:id/api-keys

Path parameters

NameTypeRequiredDescription
idstringRequiredThe id value from the endpoint path.

Request body

NameTypeRequiredDescription
namestringRequiredHuman-readable label for this key. Trimmed; 1–120 characters.
expires_atstringOptionalOptional ISO 8601 expiry datetime. Omit to create a non-expiring key.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/service-accounts/9f7c9d3a-1234-5678-9abc-def012345678/api-keys \
  -X POST \
  -H "Authorization: Bearer $CORTEX_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"name":"Sales assistant"}'

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404Resource not found in the caller's organization.`{ error, code, request_id }`
422Request body failed validation.`{ error, code, request_id }`
403Developer access required — caller lacks `is_developer = true`.`{ error, code, request_id }`
201 Createdjson
{
  "id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d",
  "prefix": "ctxk_live_",
  "name": "prod-deploy",
  "role": "member",
  "organization_id": "f1ba15e0-ebe8-4187-afe6-03ccb25b8815",
  "service_account_id": "9f7c9d3a-1234-5678-9abc-def012345678",
  "created_by_user_id": "0ce6409a-3bfa-4e2f-883a-5a696b451d8b",
  "created_at": "2026-05-21T10:00:00.000Z",
  "last_used_at": null,
  "expires_at": null,
  "revoked_at": null,
  "key": "ctxk_live_4f8a2d1c9e7b0f3a6d5c8e2b4a7f1d9c3e6b0a8f2d5c7e9b1a3f6d0c4e8b2a"
}

Revoke API key

Revoke an API key — sets `revoked_at` and immediately prevents further use (subsequent requests with this key return 401). Returns 404 if the key does not exist or belongs to a different service account. Returns 204 on success.

DELETE/v1/service-accounts/:id/api-keys/:keyId

Path parameters

NameTypeRequiredDescription
idstringRequiredThe id value from the endpoint path.
keyIdstringRequiredThe keyId value from the endpoint path.
Example requestbash
curl https://api.cortex.cognit-dx.com/v1/service-accounts/9f7c9d3a-1234-5678-9abc-def012345678/api-keys/f6a7b8c9-0123-4567-89ab-cdef01234567 \
  -X DELETE \
  -H "Authorization: Bearer $CORTEX_TOKEN"

Response codes

StatusMeaningBody
401Missing or invalid credential.`{ error, code, request_id }`
404Resource not found in the caller's organization.`{ error, code, request_id }`
403Developer access required — caller lacks `is_developer = true`.`{ error, code, request_id }`
204 No Contenttext