API reference

This API reference lists every customer-facing endpoint in Nooknear API v0.1. The base URL is https://api.nooknear.com. The interactive Swagger UI is at api.nooknear.com/documentation and the OpenAPI JSON at https://api.nooknear.com/documentation/json.

All endpoints (except GET /health) require the X-API-Key header. For the error format and rate limit headers, see Errors and limits.

There are also admin-only endpoints, such as creating accounts, changing plans and status, and deleting accounts. They require a separate admin key and can’t be called with a customer key. The payment provider’s internal webhook endpoint is also out of scope here.

Media

POST /v1/media/upload-request

Creates an asset and returns a signed URL for direct upload. Supports Idempotency-Key.

Body:

Field Type Required Notes
resourceType string Yes ^[a-zA-Z0-9-]{1,50}$
resourceId string Yes ^[a-zA-Z0-9_-]{1,128}$
filename string Yes 1–255 characters
mimeType string Yes image/jpeg, image/png, image/webp, image/gif, image/avif
sizeBytes integer Yes ≤ 10,485,760
outputFormats string[] No webp, jpeg
tags string[] No ≤ 20, each ^[a-zA-Z0-9:_.-]{1,64}$
metadata object No ≤ 4 KB as JSON
curl -X POST https://api.nooknear.com/v1/media/upload-request \
  -H "X-API-Key: $NOOKNEAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"resourceType":"event","resourceId":"123","filename":"poster.png","mimeType":"image/png","sizeBytes":1048576,"outputFormats":["webp","jpeg"]}'

201 Created:

{
  "uploadUrl": "https://...r2.cloudflarestorage.com/...",
  "assetId": "b2a1c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
  "expiresAt": "2026-12-06T12:15:00.000Z"
}

Then send the file with PUT uploadUrl and a Content-Type: <mimeType> header. Details in Uploads.

GET /v1/media/:assetId

Returns the asset’s status, tags, metadata and CDN URLs.

Parameter In Notes
assetId path UUID
curl https://api.nooknear.com/v1/media/b2a1c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d \
  -H "X-API-Key: $NOOKNEAR_API_KEY"

200 OK:

{
  "assetId": "b2a1c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
  "status": "ready",
  "resourceType": "event",
  "resourceId": "123",
  "tags": [],
  "metadata": {},
  "variants": {
    "large": {
      "url": "https://cdn.nooknear.com/<tenantId>/event/123/b2a1c3d4-.../large.webp?token=...",
      "width": 1200, "height": 800, "sizeBytes": 48210, "mimeType": "image/webp"
    },
    "jpeg": {
      "url": "https://cdn.nooknear.com/<tenantId>/event/123/b2a1c3d4-.../jpeg.jpg?token=...",
      "width": 2048, "height": 1365, "sizeBytes": 412345, "mimeType": "image/jpeg"
    }
  },
  "original": {
    "url": "https://cdn.nooknear.com/.../original.webp?token=...",
    "sizeBytes": 1048576,
    "mimeType": "image/png"
  },
  "createdAt": "2026-12-06T12:00:00.000Z"
}

variants is empty until status is ready. Deleted assets return 404.

GET /v1/media

Lists and filters assets.

Parameter In Notes
resourceType query Optional
resourceId query Optional
status query pending, processing, ready, failed, deleted
tags query Comma-separated; all must match
metadata query URL-encoded JSON object; containment (@>)
page query Default 1
limit query Default 20, max 100
curl "https://api.nooknear.com/v1/media?resourceType=event&tags=poster&limit=50" \
  -H "X-API-Key: $NOOKNEAR_API_KEY"

200 OK:

{
  "assets": [
    {
      "assetId": "b2a1c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d",
      "status": "ready",
      "resourceType": "event",
      "resourceId": "123",
      "tags": ["poster"],
      "metadata": {},
      "variants": { "small": { "url": "https://cdn.nooknear.com/.../small.webp?token=...", "width": 400, "height": 267, "sizeBytes": 17020, "mimeType": "image/webp" } },
      "originalUrl": "https://cdn.nooknear.com/.../original.webp?token=...",
      "createdAt": "2026-12-06T12:00:00.000Z"
    }
  ],
  "total": 1,
  "page": 1,
  "limit": 50
}

Details in Listing and filtering.

PATCH /v1/media/:assetId

Updates tags and/or metadata. At least one of tags or metadata is required.

Field Type Notes
tags string[] Replaces the stored list
metadata object Shallow-merged by default
mergeMetadata boolean Default true; false replaces metadata entirely
curl -X PATCH https://api.nooknear.com/v1/media/b2a1c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d \
  -H "X-API-Key: $NOOKNEAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"tags":["poster","2026"],"metadata":{"hall":"A"}}'

200 OK:

{ "assetId": "b2a1c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d", "tags": ["poster", "2026"], "metadata": { "hall": "A" } }

DELETE /v1/media/:assetId

Marks the asset deleted and queues file removal. Supports Idempotency-Key.

curl -X DELETE https://api.nooknear.com/v1/media/b2a1c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d \
  -H "X-API-Key: $NOOKNEAR_API_KEY"

200 OK:

{ "deletionJobId": "1287" }

POST /v1/media/download-token

Returns the HMAC token used in CDN URLs.

Field Type Notes
resourceType string Required in the Swagger schema
resourceId string Required in the Swagger schema
assetId string (UUID) Needed for a token that matches a CDN URL
expiresInSeconds integer ≤ 86400, default 3600; not enforced today
curl -X POST https://api.nooknear.com/v1/media/download-token \
  -H "X-API-Key: $NOOKNEAR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"resourceType":"event","resourceId":"123","assetId":"b2a1c3d4-5e6f-4a7b-8c9d-0e1f2a3b4c5d"}'

200 OK:

{ "token": "9b1e...c04a", "expiresAt": null }

Tokens don’t expire today and stay valid until the asset is deleted. Details in Variants and CDN.

Account (tenant)

tenantId in these endpoints is the account ID sent to you at signup. Calling with another ID returns 403.

GET /v1/tenants/:tenantId

curl https://api.nooknear.com/v1/tenants/$TENANT_ID \
  -H "X-API-Key: $NOOKNEAR_API_KEY"

200 OK:

{
  "tenantId": "8d2f...",
  "name": "Example Agency",
  "email": "dev@example.com",
  "plan": "pro",
  "status": "active",
  "allowedOrigins": [],
  "createdAt": "2026-11-02T08:00:00.000Z",
  "updatedAt": "2026-12-01T10:00:00.000Z"
}

PATCH /v1/tenants/:tenantId/rotate-key

Generates a new API key; the old key stops working immediately. Supports Idempotency-Key.

curl -X PATCH https://api.nooknear.com/v1/tenants/$TENANT_ID/rotate-key \
  -H "X-API-Key: $NOOKNEAR_API_KEY"

200 OK:

{ "apiKey": "np_..." }

GET /v1/tenants/:tenantId/usage

curl https://api.nooknear.com/v1/tenants/$TENANT_ID/usage \
  -H "X-API-Key: $NOOKNEAR_API_KEY"

200 OK:

{
  "tenantId": "8d2f...",
  "storageUsedBytes": 52428800,
  "uploadCount": 312,
  "downloadCount": 0,
  "bandwidthEgressBytes": 0,
  "quotaBytes": 10737418240,
  "quotaUsedPercent": 0.49,
  "plan": "pro",
  "billingPeriodStart": "2026-12-01T00:00:00.000Z",
  "billingPeriodEnd": "2026-12-31T23:59:59.000Z"
}

GET /v1/tenants/:tenantId/billing-usage

Returns usage totals for the billing period.

200 OK:

{
  "tenantId": "8d2f...",
  "plan": "pro",
  "billingPeriodStart": "2026-12-01T00:00:00.000Z",
  "billingPeriodEnd": "2026-12-31T23:59:59.000Z",
  "storageUsedBytes": 52428800,
  "uploadCount": 312,
  "downloadCount": 0,
  "bandwidthEgressBytes": 0
}

GET /v1/tenants/:tenantId/audit-log

Parameter In Notes
action query upload, download, delete, access, plan_change, api_key_rotate, failure
from, to query ISO 8601 timestamps
page query Default 1
limit query Default 20, max 100

200 OK:

{
  "logs": [
    { "id": "…", "tenantId": "8d2f...", "action": "upload", "assetId": "b2a1c3d4-...", "details": { "resourceType": "event", "resourceId": "123", "sizeBytes": 1048576 }, "ipAddress": "203.0.113.10", "userAgent": "node", "timestamp": "2026-12-06T12:00:00.000Z" }
  ],
  "total": 1,
  "page": 1,
  "limit": 20
}

GDPR

GET /v1/tenants/:tenantId/data-export

Streams account data as NDJSON (Content-Type: application/x-ndjson). Each line is {"type": "tenant" | "usage" | "asset" | "audit_log", "data": {...}}.

curl https://api.nooknear.com/v1/tenants/$TENANT_ID/data-export \
  -H "X-API-Key: $NOOKNEAR_API_KEY" -o export.ndjson

POST /v1/tenants/:tenantId/data-delete

Queues deletion of the entire account. Irreversible; the API key stops working immediately.

202 Accepted:

{ "deletionJobId": "58", "estimatedCompletion": "2026-12-06T13:00:00.000Z" }

Details in GDPR.

Health

GET /health

No authentication. Returns database, Redis and storage checks.

curl https://api.nooknear.com/health

200 OK (503 with "status": "degraded" if a check fails):

{ "status": "ok", "checks": { "database": "ok", "redis": "ok", "storage": "ok" } }