Method
keys.create
Create an API key.
Details
- Endpoint
- POST /v0/keys
- Credits
- Free
- Rate class
- Light. Counts against your light requests per second.
Creates a key for the signed-in account and returns it once in `key`. Optional `allowedOrigins` (for browser use, like `app.example.com` or `*.example.com`) and `allowedIps` (exact address or IPv4 CIDR) restrict where the key works. The plan sets how many keys you can hold. Needs a session token.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | A label for you, up to 60 characters. |
| allowedOrigins | array of string | Browser origins allowed to use the key. Empty means any. |
| allowedIps | array of string | IP addresses or IPv4 CIDR ranges allowed. Empty means any. |
Request
Send your key in the x-api-key header, or leave it out to use the keyless tier.
curl
curl -X POST "https://api.tide.ad/v0/keys" \
-H "x-api-key: YOUR_API_KEY" \
-H "content-type: application/json" \
-d '{
"name": "backend",
"allowedOrigins": [
"app.example.com"
]
}'TypeScript
const res = await fetch("https://api.tide.ad/v0/keys", {
method: "POST",
headers: {
"x-api-key": process.env.TIDE_API_KEY!,
"content-type": "application/json",
},
body: JSON.stringify({
"name": "backend",
"allowedOrigins": [
"app.example.com"
]
}),
});
const data = await res.json();Response
JSON
{
"key": "tide_...",
"id": "kid_abc123",
"name": "backend"
}