Skip to content
Esc
↑↓navigate↵open⌘Jpreview

Create a partner tenant API key

Defaults to partner administration, including customer, configuration, publishing, and key management. Billing and team membership are excluded. Explicit permissions narrow the grant. The secret is returned once. Create a replacement, update your integration, then revoke the old key to rotate.

POST/v1/tenants/{tenantId}/api-keys
Authorization
AuthorizationBearer token · headerrequired

Better Auth session, OAuth access token, OAuth client-credentials token, or sfm_ Space machine credential.

Path parameters
tenantIdstringrequired

Tenant id. Must be the credential's own tenant.

min length 1
Request body
requiredapplication/json
namestring

Human-readable key name.

min length 1 · max length 255
permissionsstring[]

Finite permission set the derived policy grants, and nothing beyond it.

min items 1 · max items 64
metadataobject

Caller-supplied metadata.

ipAllowliststring[] | null

CIDR/IP allowlist for the new key.

Show properties
Any of:
string[]
Array of string
string
null
null
expiresAtstring<date-time> | string | null

Expiry instant.

Show properties
Any of:
string<date-time> | string
Any of:
string<date-time>
string<date-time>
string
string
null
null
notBeforestring<date-time> | string | null

Activation instant.

Show properties
Any of:
string<date-time> | string
Any of:
string<date-time>
string<date-time>
string
string
null
null
Responses
201

Response for status 201

$schemastring<uri>

Canonical JSON Schema URL for this response body. The server also sends it in the Link: rel="describedby" response header.

dataobjectrequired
Show properties
idstringrequired

API key id.

namestring | nullrequired

Human-readable key name.

tenantIdstring | nullrequired

Tenant the key belongs to.

modestringrequired

test when the key belongs to a linked test tenant, live otherwise.

Allowed:livetest
subjectobject | nullrequired

Subject the key acts as.

Show properties
Any of:
object
typestringrequired

Subject kind the key acts as in audit records.

Allowed:userteamexternalsystem
idstringrequired

Stable subject id.

min length 1
null
null
ownerPrincipalobject | nullrequired

Owning principal (ownership metadata, never the authorization gate).

Show properties
Any of:
object
typestringrequired

Principal type that owns this key.

Allowed:teamexternal
idstringrequired

Stable principal id (Better Auth team id, or external id).

min length 1
null
null
createdByUserIdstring | nullrequired

User who created the key, or null for automation. Tenant-key creators are recorded for audit and do not own the key's authority.

collectionstringrequired

Disjoint resource collection this key addresses.

Allowed:teamtenant
presetstring | nullrequired

Preset the policy was compiled from, if any.

Show properties
Any of:
string
string
null
null
teamScopeobject | nullrequired

Membership-following team scope for a device-login key, or null for legacy keys.

Show properties
Any of:
object
One of:
object
modestringrequired
object
modestringrequired
teamIdsstring[]required
min items 1 · max items 100
object
modestringrequired
null
null
policyobject | nullrequired

Effective access policy. A key authorizes by policy only.

Show properties
Any of:
object
versionstringrequired

Must be the current platform policy version.

statementsobject[]required

Evaluation order: explicit deny wins, explicit allow permits, otherwise implicit deny.

min items 1
Show properties
Array of object
effectstringrequired

Explicit deny always wins over allow.

Allowed:allowdeny
actionsstring[]required

Actions this statement covers.

min items 1
resourcesstring[]required

Resource URIs this statement covers (wildcards cover subtrees).

min items 1
conditionsobject

AND condition attributes. Unresolvable attributes fail closed: no match for allow, and match for deny.

Show properties
request.clientstring

Restricts the statement to one resolved request client.

Allowed:dashboardcliapiworker
null
null
metadataobjectrequired

Caller-supplied metadata.

secretPreviewstringrequired

Masked secret preview (prefix and last characters).

notBeforestring<date-time> | nullrequired

Key is rejected before this instant.

Show properties
Any of:
string<date-time>
string<date-time>
null
null
expiresAtstring<date-time> | nullrequired

Key is rejected from this instant.

Show properties
Any of:
string<date-time>
string<date-time>
null
null
ipAllowliststring[] | nullrequired

CIDR/IP allowlist. Requests from other addresses are rejected.

Show properties
Any of:
string[]
Array of string
string
null
null
revokedAtstring<date-time> | nullrequired

Revocation instant.

Show properties
Any of:
string<date-time>
string<date-time>
null
null
enabledbooleanrequired

Whether the key currently authenticates.

createdAtstring<date-time>required

Creation instant.

matches ^(?:(?:\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))$
updatedAtstring<date-time>required

Last update instant.

matches ^(?:(?:\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))$
lastRequestAtstring<date-time> | nullrequired

Last authenticated request instant.

Show properties
Any of:
string<date-time>
string<date-time>
null
null
secretstringrequired
default

Problem details (RFC 9457). Any 4xx/5xx response is one application/problem+json document.

$schemastring<uri>

Canonical JSON Schema URL for this response body. The server also sends it in the Link: rel="describedby" response header.

typestringrequired

Problem type URI resolving to the error docs page. The server derives it mechanically from code against the docs origin.

titlestringrequired

Short human-readable summary of the problem type. The server derives it mechanically from code.

statusintegerrequired

HTTP status code of this response, repeated in the body.

min -9007199254740991 · max 9007199254740991
detailstringrequired

Human-readable failure explanation for this occurrence.

codestringrequired

Stable snake_case error code naming the failed public contract.

pointerstring

RFC 6901 JSON Pointer into the failing request field, for example "/files/37/path", on validation failures.

detailsobject

Machine-readable context for the error code.

fixstring

One sentence on what to do about this error code, the same text as the type page. Read it before retrying.

suggestionsstring[]

Actionable recovery steps safe to show in dashboards, SDKs, and CLI output.

nextstring[]

Copy-pasteable commands or API requests an agent can run next.

requestIdstringrequired

The request id to quote when contacting support.

Try it
Server
Authorization
Parameters
Bodyapplication/json
Request
curl -X POST 'https://api.spacefast.com/v1/tenants/string/api-keys' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "string",
  "permissions": [
    "spaces:read"
  ],
  "metadata": {
    "property1": null,
    "property2": null
  },
  "ipAllowlist": [
    "string"
  ],
  "expiresAt": "2019-08-24T14:15:22Z",
  "notBefore": "2019-08-24T14:15:22Z"
}'
Response
{
  "$schema": "http://example.com",
  "data": {
    "id": "string",
    "name": "string",
    "tenantId": "string",
    "mode": "live",
    "subject": {
      "type": "user",
      "id": "string"
    },
    "ownerPrincipal": {
      "type": "team",
      "id": "string"
    },
    "createdByUserId": "string",
    "collection": "team",
    "preset": "ci_deploy",
    "teamScope": {
      "mode": "all"
    },
    "policy": {
      "version": "2026-06-09",
      "statements": [
        {
          "effect": "allow",
          "actions": [
            "spaces:read"
          ],
          "resources": [
            "string"
          ],
          "conditions": {
            "request.client": "dashboard"
          }
        }
      ]
    },
    "metadata": {
      "property1": null,
      "property2": null
    },
    "secretPreview": "string",
    "notBefore": "2019-08-24T14:15:22Z",
    "expiresAt": "2019-08-24T14:15:22Z",
    "ipAllowlist": [
      "string"
    ],
    "revokedAt": "2019-08-24T14:15:22Z",
    "enabled": true,
    "createdAt": "2019-08-24T14:15:22Z",
    "updatedAt": "2019-08-24T14:15:22Z",
    "lastRequestAt": "2019-08-24T14:15:22Z",
    "secret": "string"
  }
}

Was this page helpful?