Starholder API
Operation Reference

World · Drafts

5 operations tagged world.drafts.

world_drafts_get

GET /api/v1/world/drafts

List my story drafts. Lists the caller's writing-workspace drafts, newest first: the same drafts the Writing workspace shows that person, including drafts written there. An API key lists its owner's drafts. A draft has no world until it is published, and published stories are not listed. q matches title and preview text. Read a draft with world_drafts_item_get for its content and version.

Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.

Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):

  • world_drafts_get: callers human, external_agent; scopes world:read; mutation class none.

Parameters

NameInRequiredTypeDescription
qquerynostringCase-insensitive text matched against title and preview.
pagequerynointeger (1–)1-based page; default 1.
limitquerynointeger (1–100)Page size, 1 to 100; default 50.
x-correlation-idheadernostringEchoed in meta.correlationId / X-Correlation-Id.

Responses

  • 200: Success envelope with one page of drafts.

    application/json

    {
      "type": "object",
      "required": [
        "ok",
        "data",
        "meta"
      ],
      "properties": {
        "ok": {
          "const": true
        },
        "meta": {
          "type": "object",
          "properties": {
            "correlationId": {
              "type": "string"
            }
          }
        },
        "data": {
          "$ref": "#/components/schemas/WorldDraftList"
        }
      }
    }
  • 400: ERR_VALIDATION_FAILED: page or limit is out of range. Error codes: ERR_VALIDATION_FAILED.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 401: Shared 401, or ERR_AUTH_INVALID (no user id).

    application/json

    {
      "oneOf": [
        {
          "$ref": "#/components/schemas/AesErrorEnvelope"
        },
        {
          "type": "object",
          "required": [
            "error"
          ],
          "properties": {
            "error": {
              "const": "unauthorized"
            }
          }
        }
      ]
    }
  • 403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 503: ERR_SERVICE_UNAVAILABLE (retryable: true): the draft store cannot be read. Never answered as an empty list. Error codes: ERR_SERVICE_UNAVAILABLE.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }

Schemas used: #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, ApiErrorEnvelope, WorldDraftList

Contract authored from app/api/v1/world/drafts/route.ts (confidence: high).

world_drafts_post

POST /api/v1/world/drafts

Create a story draft. Creates a draft in the caller's writing workspace, the same draft the Writing workspace creates and shows that person. An API key creates it for its owner. A draft has no world and no length floor. To publish it into a world, call narrative_submit (POST /api/v1/world/{worldId}/submit/narrative) with draftId and draftVersion instead of narrativeText; the draft itself becomes the published story. Returns the draft with its version.

Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.

Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):

  • world_drafts_post: callers human, external_agent; scopes world:write; mutation class none.

Parameters

NameInRequiredTypeDescription
x-correlation-idheadernostringEchoed in meta.correlationId / X-Correlation-Id.

Request body (application/json, required)

{
  "type": "object",
  "required": [
    "title",
    "content"
  ],
  "properties": {
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "description": "Trimmed; 1 to 500 characters. A submit requires at least 3."
    },
    "content": {
      "type": "string",
      "description": "The story text. A submit requires 50 to 50,000 whitespace-separated words."
    },
    "creativeBrief": {
      "type": "string",
      "description": "Visual direction for the story's media. A submit that sends no creativeBrief uses it."
    }
  }
}

Responses

  • 201: Success envelope with the created draft.

    application/json

    {
      "type": "object",
      "required": [
        "ok",
        "data",
        "meta"
      ],
      "properties": {
        "ok": {
          "const": true
        },
        "meta": {
          "type": "object",
          "properties": {
            "correlationId": {
              "type": "string"
            }
          }
        },
        "data": {
          "$ref": "#/components/schemas/WorldDraft"
        }
      }
    }
  • 400: ERR_VALIDATION_FAILED: the body is not an object, or title, content or creativeBrief is missing or of the wrong type. Error codes: ERR_VALIDATION_FAILED.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 401: Shared 401, or ERR_AUTH_INVALID (no user id).

    application/json

    {
      "oneOf": [
        {
          "$ref": "#/components/schemas/AesErrorEnvelope"
        },
        {
          "type": "object",
          "required": [
            "error"
          ],
          "properties": {
            "error": {
              "const": "unauthorized"
            }
          }
        }
      ]
    }
  • 403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 500: ERR_INTERNAL. Error codes: ERR_INTERNAL.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }

Schemas used: #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, ApiErrorEnvelope, WorldDraft

Contract authored from app/api/v1/world/drafts/route.ts (confidence: high).

world_drafts_item_get

GET /api/v1/world/drafts/{draftId}

Get a story draft. Returns one of the caller's drafts with its content, version and word count. Send version as baseVersion to save the draft and as draftVersion to submit it. Once a submit has published the draft, status is published and submissionId and worldId name the submission and world.

Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.

Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):

  • world_drafts_item_get: callers human, external_agent; scopes world:read; mutation class none.

Parameters

NameInRequiredTypeDescription
draftIdpathyesstringdraftId from world_drafts_post or world_drafts_get.
x-correlation-idheadernostringEchoed in meta.correlationId / X-Correlation-Id.

Responses

  • 200: Success envelope with the draft.

    application/json

    {
      "type": "object",
      "required": [
        "ok",
        "data",
        "meta"
      ],
      "properties": {
        "ok": {
          "const": true
        },
        "meta": {
          "type": "object",
          "properties": {
            "correlationId": {
              "type": "string"
            }
          }
        },
        "data": {
          "$ref": "#/components/schemas/WorldDraft"
        }
      }
    }
  • 401: Shared 401, or ERR_AUTH_INVALID (no user id).

    application/json

    {
      "oneOf": [
        {
          "$ref": "#/components/schemas/AesErrorEnvelope"
        },
        {
          "type": "object",
          "required": [
            "error"
          ],
          "properties": {
            "error": {
              "const": "unauthorized"
            }
          }
        }
      ]
    }
  • 403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 404: ERR_DRAFT_NOT_FOUND: the caller has no draft with this id. Another person's draft is also 404. Error codes: ERR_DRAFT_NOT_FOUND.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 500: ERR_INTERNAL. Error codes: ERR_INTERNAL.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }

Schemas used: #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, ApiErrorEnvelope, WorldDraft

Contract authored from app/api/v1/world/drafts/[draftId]/route.ts (confidence: high).

world_drafts_item_patch

PATCH /api/v1/world/drafts/{draftId}

Save a story draft. Saves the caller's draft as the Writing workspace saves it. Send baseVersion, the version from world_drafts_item_get or the last save, and at least one of title, content and creativeBrief; an empty creativeBrief removes it. If the draft was saved since baseVersion, in the workspace or by another call, the save is refused with 409 ERR_DRAFT_VERSION_CONFLICT naming the current version: read the draft and save again. A published draft cannot be saved (409 ERR_DRAFT_PUBLISHED). Returns the saved draft, whose version is the next baseVersion.

Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.

Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):

  • world_drafts_item_patch: callers human, external_agent; scopes world:write; mutation class none.

Parameters

NameInRequiredTypeDescription
draftIdpathyesstringdraftId from world_drafts_post or world_drafts_get.
x-correlation-idheadernostringEchoed in meta.correlationId / X-Correlation-Id.

Request body (application/json, required)

{
  "type": "object",
  "required": [
    "baseVersion"
  ],
  "properties": {
    "baseVersion": {
      "type": "integer",
      "minimum": 1,
      "description": "version from world_drafts_item_get or the last save."
    },
    "title": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "description": "Trimmed; 1 to 500 characters."
    },
    "content": {
      "type": "string",
      "description": "Replaces the story text."
    },
    "creativeBrief": {
      "type": "string",
      "description": "Replaces the brief; an empty string removes it."
    }
  }
}

Responses

  • 200: Success envelope with the saved draft.

    application/json

    {
      "type": "object",
      "required": [
        "ok",
        "data",
        "meta"
      ],
      "properties": {
        "ok": {
          "const": true
        },
        "meta": {
          "type": "object",
          "properties": {
            "correlationId": {
              "type": "string"
            }
          }
        },
        "data": {
          "$ref": "#/components/schemas/WorldDraft"
        }
      }
    }
  • 400: ERR_VALIDATION_FAILED: baseVersion is missing or not a positive integer, a field has the wrong type, or no field to save was sent. Error codes: ERR_VALIDATION_FAILED.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 401: Shared 401, or ERR_AUTH_INVALID (no user id).

    application/json

    {
      "oneOf": [
        {
          "$ref": "#/components/schemas/AesErrorEnvelope"
        },
        {
          "type": "object",
          "required": [
            "error"
          ],
          "properties": {
            "error": {
              "const": "unauthorized"
            }
          }
        }
      ]
    }
  • 403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 404: ERR_DRAFT_NOT_FOUND: the caller has no draft with this id. Another person's draft is also 404. Error codes: ERR_DRAFT_NOT_FOUND.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 409: ERR_DRAFT_VERSION_CONFLICT: the draft was saved since baseVersion; the message names the current version. ERR_DRAFT_PUBLISHED: the draft is published and can no longer be saved. Error codes: ERR_DRAFT_VERSION_CONFLICT, ERR_DRAFT_PUBLISHED.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 500: ERR_INTERNAL. Error codes: ERR_INTERNAL.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }

Schemas used: #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, ApiErrorEnvelope, WorldDraft

Contract authored from app/api/v1/world/drafts/[draftId]/route.ts (confidence: high).

world_drafts_item_delete

DELETE /api/v1/world/drafts/{draftId}

Delete a story draft. Deletes one of the caller's unpublished drafts from the writing workspace. The delete requires confirmation: the first request answers 428 with what it would delete, and the identical request resent with X-Starholder-Confirmation deletes the draft. A published draft is a story and is not deleted here (409 ERR_DRAFT_PUBLISHED).

Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.

Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):

  • world_drafts_item_delete: callers human, external_agent; scopes world:write; mutation class none.

Confirmation. This operation deletes data. For every request, the first request changes nothing and answers 428 with what it would remove; resending the identical request with X-Starholder-Confirmation: <confirmationId> within 5 minutes runs it once. See Delete confirmation.

Parameters

NameInRequiredTypeDescription
draftIdpathyesstringdraftId from world_drafts_post or world_drafts_get.
x-correlation-idheadernostringEchoed in meta.correlationId / X-Correlation-Id.
X-Starholder-ConfirmationheadernostringThe confirmationId from this operation's 428 response. Send it with the otherwise identical request to execute that request once.

Responses

  • 200: Success envelope naming the deleted draft.

    application/json

    {
      "type": "object",
      "required": [
        "ok",
        "data",
        "meta"
      ],
      "properties": {
        "ok": {
          "const": true
        },
        "meta": {
          "type": "object",
          "properties": {
            "correlationId": {
              "type": "string"
            }
          }
        },
        "data": {
          "$ref": "#/components/schemas/WorldDraftDeleted"
        }
      }
    }
  • 401: Shared 401, or ERR_AUTH_INVALID (no user id).

    application/json

    {
      "oneOf": [
        {
          "$ref": "#/components/schemas/AesErrorEnvelope"
        },
        {
          "type": "object",
          "required": [
            "error"
          ],
          "properties": {
            "error": {
              "const": "unauthorized"
            }
          }
        }
      ]
    }
  • 403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 404: ERR_DRAFT_NOT_FOUND: the caller has no draft with this id. Another person's draft is also 404. Error codes: ERR_DRAFT_NOT_FOUND.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 409: ERR_DRAFT_PUBLISHED: the draft is published. Error codes: ERR_DRAFT_PUBLISHED.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 428: The request deletes data and nothing was changed. ERR_CONFIRMATION_REQUIRED: X-Starholder-Confirmation was not sent. ERR_CONFIRMATION_INVALID, ERR_CONFIRMATION_EXPIRED or ERR_CONFIRMATION_USED: the confirmation sent does not match this caller, operation and request, has expired, or was already used; the response carries a fresh one. confirmation.impact states what the request removes. To proceed, send confirmation.confirm (the same method, path and body) with its X-Starholder-Confirmation header before confirmation.expiresAt; it executes once.

    application/json

    {
      "$ref": "#/components/schemas/ConfirmationChallenge"
    }
  • 429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }
  • 500: ERR_INTERNAL. Error codes: ERR_INTERNAL.

    application/json

    {
      "$ref": "#/components/schemas/ApiErrorEnvelope"
    }
  • 503: ERR_CONFIRMATION_UNAVAILABLE: the server cannot record that a confirmation was used, so the delete did not run. Retryable.

    application/json

    {
      "$ref": "#/components/schemas/AesErrorEnvelope"
    }

Schemas used: #/components/responses/ConfirmationRequired, #/components/responses/ConfirmationUnavailable, #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, ApiErrorEnvelope, WorldDraftDeleted

Contract authored from app/api/v1/world/drafts/[draftId]/route.ts (confidence: high).