Create an API key
POST
/v1/api-keys
const url = 'https://your-machine.your-tailnet.ts.net/v1/api-keys';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"sales agent"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://your-machine.your-tailnet.ts.net/v1/api-keys \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "sales agent" }'The key is returned once. Store it; only its hash is kept.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
name
required
string
Example
sales agentResponses
Section titled “Responses”The new key.
Media typeapplication/json
object
apiKey
object
id
string format: uuid
name
string
prefix
string
createdAt
string format: date-time
lastUsedAt
string format: date-time
key
string
Example
{ "apiKey": { "prefix": "gw_9fJ2", "key": "gw_9fJ2kQx0b7Lw4mT1sV8yZ3cA6dE5hN2p" }}