/Docs
Search docs or ask a question⌘K
DocsAgent
Changelog
API Reference Create API Key

Create API Key

Create a new API key for a project.

POST/v1/projects/{projectId}/api-keysTry it
Session token

Create a new API key. The full key is returned only once, in this response — store it securely. Syntext keeps only a one-way hash of it.

Note

Requires the admin or owner role. A member of the workspace gets 403 forbidden ("Only workspace admins can create API keys.") with details.requiredRole and details.currentRole. Any member can list keys.

Path Parameters

NameDescription
projectId:stringpathRequired
The project ID.

Request Body

NameDescription
name:stringbodyRequired
A descriptive name (1–100 chars), e.g. "CI deploy key".
scope:stringbody
One of full, build, or read.
Default"full"
expiresInDays:integerbody
Optional expiry, 1–365 days. Omit for a non-expiring key.

Response — 201 Created

Warning

The key field is only returned at creation (and on rotation). If you lose it, rotate the key — it cannot be retrieved.

Key Format

Keys look like stx_{8-char prefix}_{secret}. The prefix is safe to display and log; the full key is a secret.

last4 holds the last four characters of the full key, so you can show a masked key such as stx_a1b2c3d4_…Once without storing the secret. It is stored when the key is created or rotated.

Was this page helpful? Yes No
Request
cURLJavaScriptPythonGoRubyPHPJavaC#cURL
curl -X POST https://api.syntext.dev/v1/projects/3f2a9c1e-8b4d-4e7a-9c21-5d6e7f8a9b0c/api-keys \
-H "Authorization: Bearer $SYNTEXT_JWT" \
-H "Content-Type: application/json" \
-d '{
"name": "CI deploy key",
"scope": "build",
"expiresInDays": 90
}'
Responseapplication/json
201Created
{
"data": {
"id": "key_789",
"name": "CI deploy key",
"key": "stx_a1b2c3d4_9XyZ...fullKeyShownOnlyOnce",
"prefix": "stx_a1b2c3d4",
"last4": "Once",
"scope": "build",
"expiresAt": "2026-10-01T10:00:00Z",
"createdAt": "2026-07-03T10:00:00Z"
}
}
Product
Resources
Company
© 2026 SyntextBuilt with Syntext