레퍼런스HTTP APIA P I keys

Issue a personal key or an agent key

POST
/v1/api-keys

A personal key is the caller's own; an agent key names its agent in agent_id and takes an owner, an admin, or that agent's admin. No key reaches a whole workspace: an agent key without agent_id is a 400. name (1-64 characters once trimmed) is optional. scopes may not exceed what the caller holds now (403 SCOPE_NOT_GRANTABLE); within that, either kind may hold any scope, sessions:approve included. A personal or agent key holding sessions:approve still never approves a session it started itself. An API key never issues one. The secret is returned once; only its sha256 is stored. Writes a create_api_key receipt.

Auth: cookie session only; no scope. Idempotency-Key: ignored.

Authorization

cookieSession
cookie__Host-werft_session<token>

For the web console: the browser session cookie set by POST /v1/auth/login. It holds the scopes of the user's workspace role (owner: all; admin and member: all but sessions:recover). Requests other than GET must also send X-Requested-With: werft-web.

Header Parameters

X-Requested-With?"werft-web"

Required with a cookie session: the literal werft-web.

Value in"werft-web"

Request Body

application/json
  1. body
kind*string
Value in"personal""agent"
name?string

A label the issuer gives the key, so a list tells one integration's key from another's.

Length1 <= length <= 64
scopes*array<>
Items1 <= items
agent_id?string
Match^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
Formatuuid
expires_at?string
Match^(?:(?:\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))$
Formatdate-time

Response Body

Success

application/json
  1. response
key*
secret*string
Length32 <= length <= 256
receipt_id*string
Match^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$
Formatuuid
Example Request
curl -X POST 'https://example.com/v1/api-keys' \  -H 'Content-Type: application/json' \  -d '{  "kind": "personal",  "scopes": [    "sessions:read"  ]}'
Example Response
{  "key": {    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",    "kind": "personal",    "name": "string",    "workspace_id": "0967198e-ec7b-4c6b-b4d3-f71244cadbe9",    "agent_id": "2b1e3b65-2c04-4fa2-a2d7-467901e98978",    "created_by": "ee824cad-d7a6-4f48-87dc-e8461a9201c4",    "created_by_user": {      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",      "display_name": "string"    },    "scopes": [      "sessions:read"    ],    "created_at": "2019-08-24T14:15:22Z",    "expires_at": "2019-08-24T14:15:22Z",    "revoked_at": "2019-08-24T14:15:22Z",    "last_used_at": "2019-08-24T14:15:22Z"  },  "secret": "stringstringstringstringstringst",  "receipt_id": "64d0a161-468e-472a-b00e-a06ee9ab7de7"}