PilotFoxDocs

Create an API key

POST
/api/v1/orgs/{orgId}/api-keys

Only a signed-in member can create a key: an API key gets 403 here whatever it holds (keys never create keys), so the apiKey:create below must come from the member's role. The new key holds the requested permissions that role can grant (admins and owners may also grant the API-key-only ingest:write and revenue:write; 400 when none can be granted), on the sites in siteIds (400 for an id that is not a live site of the organization), or on every site of the organization when it is absent. expiresInDays (1 to 3650) sets an expiry; none by default. This answer is the only one that carries key. 409 once the organization has its maximum of active keys (API_KEY_MAX_PER_ORG, 50 by default).

Requires apiKey:create in the organization (an API key, or a signed-in member's role; a member restricted to some sites holds a viewer's permissions here). API keys limited to some sites: 403. Share links: 401.

Authorization

headerx-api-key<token>

An organization API key (ak_…), with the permissions and the sites it was created with. For servers and scripts: no cookie and no Origin check. Also accepted as Authorization: Bearer ak_… (apiKeyBearer). A request carries one credential: a key sent with a share token or a live session cookie is 400 (details.reason: ambiguous_credentials).

Scope: apiKey:create

Path Parameters

orgId*string

Request Body

application/json
  1. body
name*string
Length1 <= length <= 64
permissions*
siteIds?array<string>
Items1 <= items <= 500
expiresInDays?integer
Range1 <= value <= 3650

Response Body

Created

application/json
  1. response
data*
Example Request
curl -X POST 'https://pilotfox.app/api/v1/orgs/string/api-keys' \  -H 'Content-Type: application/json' \  -d '{  "name": "string",  "permissions": {    "property1": [      "string"    ],    "property2": [      "string"    ]  }}'
Example Response201
{  "data": {    "id": "string",    "key": "string",    "start": "string",    "permissions": {      "property1": [        "string"      ],      "property2": [        "string"      ]    },    "siteIds": [      "string"    ],    "expiresAt": "2019-08-24T14:15:22Z"  }}