Thanks to visit codestin.com
Credit goes to draftbase.co

Draftbase

Draftbase API Reference

Every endpoint below maps directly to a resource in the Draftbase content model: templates define the schema, entries hold the content, and media handles uploads. Each route documents its request body, response shape, and status codes, generated straight from the live OpenAPI spec so it never drifts from the deployed API. Prefer calling these endpoints through a typed client instead of raw fetch calls? The SDK wraps every route here with full TypeScript types.

Raw OpenAPI spec (JSON)@draftbase/sdk on GitHub
GET/agents/types

List available agent types

The prebuilt agent catalog, with each type's lock status under the org's current plan. Every type can be instantiated more than once — these are templates, not singletons.

Request

Terminal
curl -X GET "https://api.draftbase.co/agents/types" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Responses

200OK

The request succeeded.

Response
[
  {
    "type": "string",
    "label": "string",
    "description": "string",
    "integrationType": "string",
    "tags": [
      "string"
    ],
    "locked": true,
    "overlayFields": [
      {
        "key": null,
        "type": null,
        "optional": null,
        "defaultValue": null,
        "enumValues": null
      }
    ]
  }
]

Any endpoint can also return 401 (missing or invalid credentials), 403 (suspended org, insufficient role, or blocked IP), and 429 (100 requests per minute per IP; delivery routes add a 300 per minute per-org cap).

Error codes

Every error response carries a stable `code` alongside the human-readable `error` message. Switch on `code` — the message wording can change at any time, the code cannot.

CodeStatusMeaning
MISSING_ORG_HEADER400Missing x-org-id header
VALIDATION_FAILED400Request validation failed
INVALID_TOKEN400Invalid or expired token
INVALID_2FA_CODE400Invalid code
TWO_FACTOR_NOT_ENABLED4002FA is not enabled
TWO_FACTOR_SETUP_REQUIRED400Start setup before enabling 2FA
INCORRECT_PASSWORD400Current password is incorrect
PASSWORD_REQUIRED400Set a password before unlinking Google
DUPLICATE_FIELD_KEYS400Duplicate field keys
DUPLICATE_PROP_NAMES400Duplicate prop names
INVALID_NAME400Name must contain at least one letter or digit
UNKNOWN_ENVIRONMENT400Unknown environment
MAIN_ENVIRONMENT_IMMUTABLE400The main environment cannot be modified this way
SAME_ENVIRONMENT400Source and target environments must differ
PLAN_LIMIT_EXCEEDED400Plan limit exceeded
ALREADY_PUBLISHED400Entry is already published
PUBLISH_AT_IN_PAST400publishAt must be in the future
INVITE_NOT_PENDING400Invite is not pending
STORAGE_KEY_MISMATCH400storageKey does not belong to this org/environment
SELF_DISABLE_FORBIDDEN400Cannot disable your own account
RETRY_NOT_ALLOWED400Only failed deliveries can be retried
IDP_EMAIL_MISSING400Identity provider did not return an email
IDP_EMAIL_UNVERIFIED400Identity provider did not verify this email
ENTRY_PUBLISHED400Published entries must be unpublished before they can be deleted
NO_ACTIVE_SUBSCRIPTION400Org has no active subscription
WEBHOOK_SIGNATURE_INVALID400Invalid webhook signature
UNAUTHORIZED401Unauthorized
INVALID_CREDENTIALS401Invalid email or password
MISSING_REFRESH_TOKEN401Missing refresh token
INVALID_REFRESH_TOKEN401Invalid or expired refresh token
INVALID_CHALLENGE401Invalid or expired challenge
FORBIDDEN403Forbidden
ORG_SUSPENDED403Org is suspended
IP_NOT_ALLOWED403Request IP is not on the org's allowlist
NOT_ORG_MEMBER403Not a member of this org
INSUFFICIENT_ROLE403Insufficient role
ENVIRONMENT_FORBIDDEN403Not allowed to access this environment
OWNER_IMMUTABLE403The org owner cannot be changed or removed
PLAN_FEATURE_REQUIRED403This feature is not included in the org's plan
EMAIL_NOT_VERIFIED403Email address is not verified
NOT_INVITED403This account is not invited to this org
NO_ORG403User does not belong to an org
NOT_FOUND404Not found
REVISION_NOT_FOUND404Revision not found
SNAPSHOT_NOT_FOUND404Snapshot not found
SSO_CONNECTION_NOT_FOUND404SSO connection not found
ENVIRONMENT_NOT_FOUND404Environment not found
ALREADY_EXISTS409Already exists
EMAIL_IN_USE409Email already in use
ALREADY_MEMBER409Already a member
ALREADY_INVITED409Already invited
ENTRY_MODIFIED409Entry was modified by another request
STILL_REFERENCED409Still referenced by other content
TEMPLATE_HAS_ENTRIES409Template still has entries
AI_UNAVAILABLE502AI service is unavailable
RATE_LIMITED429Rate limit exceeded
INTERNAL_ERROR500Internal server error

Setting up a webhook

Webhooks fire signed HTTP POSTs on entry lifecycle events. Two ways to register one — there is no MCP tool for this yet, so an AI agent without dashboard access should call the API directly with a management API key.

Via the dashboard

  1. Open Webhooks in the org sidebar, click Add webhook.
  2. Enter the endpoint URL and pick the environment it should fire for.
  3. Optionally scope it to one template, and check the event groups to subscribe to (defaults to Published/Unpublished).
  4. Optionally add an auth header sent with every delivery.
  5. Create it — the signing secret is shown once. Copy it now; it cannot be retrieved again.

Via the API

POST /webhooks with a management-scoped API key. The response carries the webhook id and its secret once — nothing after this call can retrieve the secret again, so capture it from the response.

curl -X POST https://api.draftbase.co/webhooks \
  -H "Authorization: Bearer <management API key>" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/hooks/draftbase",
    "events": ["entry.published", "entry.unpublished"],
    "envId": "production",
    "includeContent": false
  }'

Events

entry.createdA new entry was created.
entry.updatedAn entry’s fields changed.
entry.status_changedAn entry moved between draft/review/etc.
entry.publishedAn entry went live.
entry.unpublishedAn entry was taken down.
entry.archivedAn entry was archived.
entry.deletedAn entry was permanently deleted.
entry.rolled_backAn entry was reverted to an earlier revision.
entry.tags_updatedOnly an entry’s tags changed, fields untouched.

Verifying deliveries

Every delivery carries X-Draftbase-Signature-256: sha256=<hex>, an HMAC-SHA256 of ${timestamp}.${body} using the webhook’s secret, plus X-Draftbase-Timestamp, X-Draftbase-Event, and X-Draftbase-Event-Id. Recompute the HMAC over the raw request body and compare — reject anything that doesn’t match.