---
raw: true
search:
  tags:
    - Spaces
    - POST
seo:
  description: >-
    Returns a bearer token, valid for ttlSeconds, for calling this… Reference
    for the POST /v1/spaces/{spaceId}/zero/token endpoint in the Spacefast
    Partner API.
sidebar:
  label: Create a short-lived token for a Space's REST API
  badge: POST
title: Create a short-lived token for a Space's REST API
type: openapi-operation
---
Returns a bearer token, valid for `ttlSeconds`, for calling this Space's own WordPress REST API with the access of one of its machine credentials (`credentialId`). Authenticate normally; you never need that credential's secret. Send the token only to the returned `endpoint`, and keep it out of logs and chat. The Space re-checks the credential's Grant on every request, so the returned capabilities and role are what to expect, not a promise.

`POST /v1/spaces/{spaceId}/zero/token`

**Request body** (`application/json`, required)

- `credentialId` (string, required) — A live machine credential of this Space. Its canonical scoped Grant is the authority the Space's own runtime re-derives the WordPress role from.
- `ttlSeconds` (integer) — How long the bearer stays valid, in seconds.

Request body example:

```json
{
  "credentialId": "string",
  "ttlSeconds": 900
}
```

**Responses**

- `200` — Response for status 200
- `default` — Problem details (RFC 9457). Any 4xx/5xx response is one \`application/problem+json\` document.

Response example, 200:

```json
{
  "$schema": "http://example.com",
  "data": {
    "token": "string",
    "expiresAt": "2019-08-24T14:15:22Z",
    "host": "string",
    "endpoint": "http://example.com",
    "credentialId": "string",
    "capabilities": [
      "page.view"
    ],
    "role": "subscriber"
  }
}
```
