Docs

Twelve endpoints, three kinds of key.

The whole surface your code talks to. The AI gateway speaks the OpenAI API, an upload asks for a signed URL, and a notification names an app and who should get it — there is nothing else to learn.

Start free trial

14 days, no card

Pick the right key

Every call is a bearer token: Authorization: Bearer <key>. There are three kinds, and choosing wrongly is the most common first mistake — a 403 almost always means the key is real but is not the one this API wants.

gw_sk_…

Server key

A general key carrying any of the scopes: Storage API, Storage delete, Push send, AI Gateway.

Dashboard → API keys

Server-side only — never ship it

gw_ai_…

AI endpoint key

One AI endpoint, with that endpoint's own model routing and budget. Opens the AI API only.

Dashboard → AI gateway → Endpoints

Server-side only — never ship it

gw_push_…

Push app key

One push app. Registers devices and reports opens — and nothing else, which is why it is the only key meant to ship inside an app.

Dashboard → Apps

Safe to ship inside an app

A key is shown once, when it is created or rotated. Only a hash is stored, so a key that is lost is rotated, never recovered.

Base URL

Every example below already uses yours:

https://api.penstoke.com

AI gateway

OpenAI-compatible. Point an existing SDK at the gateway by changing its base URL and key — the request and response bodies are the ones your client already speaks, streaming included. The response says which provider actually served it.

GET/v1/models

Every model your endpoint can route to.

Key: gw_ai_… or gw_sk_… with the AI Gateway scope

curl https://api.penstoke.com/v1/models \
  -H "Authorization: Bearer $PENSTOKE_KEY"
POST/v1/chat/completions

A chat completion, routed to your primary model and down your fallback list.

Key: gw_ai_… or gw_sk_… with the AI Gateway scope

Takes the OpenAI body: `model`, `messages`, and optionally `stream`, `temperature`, `top_p`, `max_tokens`, `max_completion_tokens`, `stop`. Unknown fields are passed through. A 429, a 5xx or a timeout moves the same request to the next provider in your order.

curl https://api.penstoke.com/v1/chat/completions \
  -H "Authorization: Bearer $PENSTOKE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [{ "role": "user", "content": "Say hello" }]
  }'

Storage gateway

Your app never holds provider credentials. It asks the gateway for a short-lived signed URL and talks to the provider directly; which bucket a path lands in is a routing rule, not something your code knows.

POST/storage/v1/presign

A signed URL to upload or download one object.

Key: gw_sk_… with the Storage API scope

`{ path, method }`, where method is `GET` or `PUT`. **A PUT must also declare `contentType` and `sizeBytes`** — both are signed into the URL, so the upload has to match exactly what was announced. `ttlMinutes` is optional and clamped by your routing rule. Uploads are namespaced per key under `uploads/<key id>/`, which is why the returned `key` differs from the path you sent.

curl -X POST https://api.penstoke.com/storage/v1/presign \
  -H "Authorization: Bearer $PENSTOKE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "path": "/photos/avatar.png",
    "method": "PUT",
    "contentType": "image/png",
    "sizeBytes": 20480
  }'
POST/storage/v1/uploads/complete

Confirms the upload, so it is indexed and counted.

Key: gw_sk_… with the Storage API scope

`{ path }` — the same path you presigned. The object is verified at the provider against the size and type it declared; one that breaks the limits is deleted there and rejected. Skip this and the next bucket sync picks the object up instead.

curl -X POST https://api.penstoke.com/storage/v1/uploads/complete \
  -H "Authorization: Bearer $PENSTOKE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "path": "/photos/avatar.png" }'
DELETE/storage/v1/objects?path=…

Removes one object this key uploaded.

Key: gw_sk_… with the Storage delete scope

The path goes in the **query string**, URL-encoded — a storage path contains slashes, and not every HTTP client sends a body on DELETE. Give it the path you uploaded with, or the `key` the presign returned; both name the same object. It reaches only this key's own uploads: never the media library, never another key's objects. Deleting twice gives 200 then 404.

curl -X DELETE "https://api.penstoke.com/storage/v1/objects?path=%2Fphotos%2Favatar.png" \
  -H "Authorization: Bearer $PENSTOKE_KEY"

# Or let curl encode it for you:
curl -X DELETE --get --data-urlencode "path=/photos/avatar.png" \
  "https://api.penstoke.com/storage/v1/objects" -H "Authorization: Bearer $PENSTOKE_KEY"
POST/storage/v1/resolve

Which bucket and provider a path routes to.

Key: gw_sk_… with the Storage API scope

`{ path }`. Useful for checking a routing rule without uploading anything.

curl -X POST https://api.penstoke.com/storage/v1/resolve \
  -H "Authorization: Bearer $PENSTOKE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "path": "/photos/avatar.png" }'

Push gateway

Two different keys, and the split is the point: the app key registers devices and reports opens, and it is the one you ship. Sending is a server key, so a decompiled app can never broadcast to your users.

POST/push/v1/devices

Registers or updates one device.

Key: gw_push_… (the app key — safe to ship)

`{ platform, token }` with platform one of IOS, ANDROID, WEB. Optionally `deviceModel`, `osVersion`, `appVersion`, `locale`, `timezone`, `tags` (replaces the device's tags) and `pushEnabled`. Answers `{ deviceId }`.

curl -X POST https://api.penstoke.com/push/v1/devices \
  -H "Authorization: Bearer $PENSTOKE_APP_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "platform": "IOS",
    "token": "<APNs device token>",
    "appVersion": "2.4.0",
    "tags": ["beta"]
  }'
DELETE/push/v1/devices/:token

Unregisters a device, on sign-out or opt-out.

Key: gw_push_… (the app key)

curl -X DELETE https://api.penstoke.com/push/v1/devices/<token> \
  -H "Authorization: Bearer $PENSTOKE_APP_KEY"
POST/push/v1/events

Reports that a notification was opened.

Key: gw_push_… (the app key)

`{ messageId, type: "opened" }`. Idempotent: `recorded` comes back false when the open was already counted, or the message was never delivered.

curl -X POST https://api.penstoke.com/push/v1/events \
  -H "Authorization: Bearer $PENSTOKE_APP_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "messageId": "<id from the payload>", "type": "opened" }'
POST/push/v1/send

Sends to up to 1,000 devices and waits for the result.

Key: gw_sk_… with the Push send scope (server only)

`{ appId, title, body, target }` plus optional `richMediaUrl`, `actionUrl` and `data` (custom string pairs, 2 KB). `target` takes `tokens`, `deviceIds`, `tags` or `platforms` — at least one. Answers `{ sent, failed, dryRun, messageIds }`.

curl -X POST https://api.penstoke.com/push/v1/send \
  -H "Authorization: Bearer $PENSTOKE_SERVER_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "appId": "<app id>",
    "title": "Your order shipped",
    "body": "Track it in the app.",
    "target": { "tags": ["customers"] },
    "actionUrl": "https://example.com/orders/42"
  }'

When it fails

Every error is the same shape, so one handler covers all of them. There is no 200 carrying a failure.

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "A PUT presign must declare `contentType` and `sizeBytes`",
    "details": { "issues": [{ "path": "sizeBytes", "message": "Required" }] }
  }
}
VALIDATION_ERROR
400
The body or query failed the schema. `details.issues` names the field.
BAD_REQUEST
400
Well-formed but impossible — no routing rule matches the path, say.
UNAUTHENTICATED
401
No key, or one that is unknown, revoked or expired.
FORBIDDEN
403
The key is valid but lacks the scope for this API, or its IP allowlist excludes you.
NOT_FOUND
404
No such object, device or app — within what this key can see.
CONFLICT
409
Something already holds that key, e.g. a completed upload at the same path.
RATE_LIMITED
429
Over your per-key rate limit. `Retry-After` says how long to wait.
QUOTA_EXCEEDED
402
A budget or plan limit would be passed by this request.
PROVIDER_ERROR
502
The upstream provider failed and no fallback was left to try.
SERVICE_UNAVAILABLE
503
Temporarily unable to serve. Safe to retry with backoff.

Dry runs

Before you add provider credentials, calls still work end to end: they are validated, routed, logged and counted exactly as they will be in production — nothing is sent upstream. The response says so with dryRun: true, and the dashboard marks those rows. It is never silent, and a dry run is never reported as a real delivery.

Signed in, this same page at your dashboard carries your own endpoint, so every line can be copied and run as it stands.