Skip to content

Create an API key

POST
/api/settings/service-accounts/{id}/keys
curl --request POST \
--url https://forge.example.com/api/settings/service-accounts/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "name": "example", "days": 1, "allowedNetworks": [ "example" ] }'

Answers the whole key, nbf_ and 38 letters and digits, this once: only its HMAC and its last four characters are kept, and it is never shown again. days is its life, the organization’s default when left out (90 days, or less when the organization’s longest is shorter) and never more than its longest; there is no key without an end. allowedNetworks lists the networks it may be used from, IPv4 or IPv6, up to 20; none means any address. An account has at most two live keys. Never cached. Needs a step-up from the last 10 minutes (409 with stepUpNeeded). For administrators.

id
required
string format: uuid
Media typeapplication/json
object
name
required
null | string
days
required
null | integer | string format: int32
/^-?(?:0|[1-9]\d*)$/
allowedNetworks
required
Array<string> | null

Example generated

{
"name": "example",
"days": 1,
"allowedNetworks": [
"example"
]
}

OK

Media typeapplication/json
object
key
required
object
id
required
string format: uuid
name
required
string
lastFour
required
string
createdAt
required
string format: date-time
createdBy
required
null | string
expiresAt
required
string format: date-time
revokedAt
required
null | string format: date-time
revokedBy
required
null | string
lastUsedAt
required
null | string format: date-time
lastUsedAddress
required
null | string
allowedNetworks
required
Array<string>
status
required
string
replaces
required
null | string format: uuid
secret
required
string

Example generated

{
"key": {
"id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0",
"name": "example",
"lastFour": "example",
"createdAt": "2026-04-15T12:00:00Z",
"createdBy": "example",
"expiresAt": "2026-04-15T12:00:00Z",
"revokedAt": "2026-04-15T12:00:00Z",
"revokedBy": "example",
"lastUsedAt": "2026-04-15T12:00:00Z",
"lastUsedAddress": "example",
"allowedNetworks": [
"example"
],
"status": "example",
"replaces": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0"
},
"secret": "example"
}

A refusal or an error, as a problem document. A model or draft you may not see answers 404, as one that does not exist.

Media typeapplication/problem+json
object
type
string
title
string
status
integer
detail
string
instance
string

Example generated

{
"type": "example",
"title": "example",
"status": 1,
"detail": "example",
"instance": "example"
}