> ## Documentation Index
> Fetch the complete documentation index at: https://docs.joip.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Rewrite captions

> Create an asynchronous job that rewrites supplied captions for one to ten public HTTPS media URLs. Repeating the request with the same Idempotency-Key returns the original job with Idempotent-Replayed: true.



## OpenAPI

````yaml /openapi.json post /v1/captions/rewrite
openapi: 3.1.0
info:
  title: Joip Public API
  version: 1.1.0
  description: >-
    Generate and rewrite captions from server-side integrations using the same
    Joip credits as the web app. This API is live-only and has no sandbox.
servers:
  - url: https://api.joip.io
    description: Live
security: []
tags:
  - name: Status
    description: Public service health.
  - name: Account
    description: API account metadata.
  - name: Credits
    description: Shared Joip credits and server-authoritative pricing.
  - name: Jobs
    description: Asynchronous caption work and per-item results.
  - name: Captions
    description: Caption generation and rewriting.
externalDocs:
  description: Joip API documentation
  url: https://docs.joip.io/api-reference/overview
paths:
  /v1/captions/rewrite:
    post:
      tags:
        - Captions
      summary: Rewrite captions
      description: >-
        Create an asynchronous job that rewrites supplied captions for one to
        ten public HTTPS media URLs. Repeating the request with the same
        Idempotency-Key returns the original job with Idempotent-Replayed: true.
      operationId: rewrite_captions
      parameters:
        - name: Idempotency-Key
          in: header
          required: true
          schema:
            type: string
            minLength: 8
            maxLength: 255
          description: >-
            Client-generated key scoped by account, method, canonical route, and
            key value.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/caption_rewrite_request'
            example:
              items:
                - media_url: https://cdn.example.com/photo.jpg
                  caption: Original caption
              rewrite_mode: improve
      responses:
        '202':
          description: Accepted
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
            X-RateLimit-Limit:
              description: Requests this API key may make in the current one-minute window.
              schema:
                type: integer
                minimum: 1
            X-RateLimit-Remaining:
              description: Requests left for this API key in the current window.
              schema:
                type: integer
                minimum: 0
            X-RateLimit-Reset:
              description: Whole seconds until this API key's rate-limit window resets.
              schema:
                type: integer
                minimum: 1
            Idempotent-Replayed:
              description: >-
                Present and true when this response replays an earlier
                acceptance with the same Idempotency-Key. Absent on the first
                acceptance.
              schema:
                type: string
                enum:
                  - 'true'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/job'
              example:
                id: 6f1c2a7e-3b5d-4c8e-9a0f-1d2e3f4a5b6c
                type: caption_rewrite
                state: queued
                created_at: '2026-11-29T18:04:11.000Z'
                updated_at: '2026-11-29T18:04:11.000Z'
                item_count: 1
                completed_item_count: 0
                failed_item_count: 0
                billing:
                  reserved_credits: 5
                  settled_credits: 0
                  released_credits: 0
                  currency: credits
        '400':
          description: The request is invalid.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#invalid_request
                title: Invalid request
                status: 400
                detail: media_urls[0] must be an https:// URL.
                instance: /v1/captions/generate
                code: invalid_request
                param: media_urls
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '401':
          description: The API key is missing, malformed, expired, or revoked.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#invalid_api_key
                title: Invalid API key
                status: 401
                detail: The public API key is invalid.
                instance: /v1/captions/generate
                code: invalid_api_key
                param: authorization
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '402':
          description: The account does not have enough available Joip credits.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#insufficient_credits
                title: Insufficient credits
                status: 402
                detail: There are not enough available credits for this request.
                instance: /v1/captions/generate
                code: insufficient_credits
                param: null
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '403':
          description: The key does not grant the required scope or IP access.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#insufficient_scope
                title: Insufficient scope
                status: 403
                detail: This API key does not grant the required operation scope.
                instance: /v1/captions/generate
                code: insufficient_scope
                param: authorization
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '404':
          description: The requested resource does not exist for this account.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#job_not_found
                title: Job not found
                status: 404
                detail: Job not found.
                instance: /v1/captions/generate
                code: job_not_found
                param: null
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '409':
          description: The request conflicts with existing state or idempotency history.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#idempotency_conflict
                title: Idempotency key conflict
                status: 409
                detail: This idempotency key was used for a different request.
                instance: /v1/captions/generate
                code: idempotency_conflict
                param: null
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '413':
          description: The JSON request body exceeds 1 MiB.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#request_too_large
                title: Request too large
                status: 413
                detail: Public API JSON request bodies cannot exceed 1 MiB.
                instance: /v1/captions/generate
                code: request_too_large
                param: null
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '415':
          description: The request body is not application/json.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#json_required
                title: JSON body required
                status: 415
                detail: Public API request bodies must use application/json.
                instance: /v1/captions/generate
                code: json_required
                param: null
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '429':
          description: The per-key request limit or job-admission limit was exceeded.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
                minimum: 1
            X-RateLimit-Limit:
              description: Requests this API key may make in the current one-minute window.
              schema:
                type: integer
                minimum: 1
            X-RateLimit-Remaining:
              description: Requests left for this API key in the current window.
              schema:
                type: integer
                minimum: 0
            X-RateLimit-Reset:
              description: Whole seconds until this API key's rate-limit window resets.
              schema:
                type: integer
                minimum: 1
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#rate_limit_exceeded
                title: Rate limit exceeded
                status: 429
                detail: This API key has exceeded 120 requests in the current minute.
                instance: /v1/captions/generate
                code: rate_limit_exceeded
                param: null
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '500':
          description: Joip could not complete the request.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#internal_error
                title: Internal error
                status: 500
                detail: The API could not complete this request.
                instance: /v1/captions/generate
                code: internal_error
                param: null
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '502':
          description: The API edge received an invalid response from the API service.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: >-
                  https://docs.joip.io/api-reference/errors#invalid_upstream_response
                title: Invalid upstream response
                status: 502
                detail: The API service returned an invalid response.
                instance: /v1/captions/generate
                code: invalid_upstream_response
                param: null
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        '503':
          description: The API or one of its required services is temporarily unavailable.
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
            Retry-After:
              description: Seconds to wait before retrying.
              schema:
                type: integer
                minimum: 1
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
              example:
                type: https://docs.joip.io/api-reference/errors#pricing_unavailable
                title: Pricing unavailable
                status: 503
                detail: Caption pricing is temporarily unavailable.
                instance: /v1/captions/generate
                code: pricing_unavailable
                param: null
                request_id: req_4f9c2b7a1e6d3c8b5a0f9e2d7c4b1a6e
        default:
          description: Error
          headers:
            X-Request-Id:
              description: Canonical Joip request identifier.
              schema:
                type: string
                pattern: ^req_[a-z0-9]{16,64}$
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/problem_details'
      security:
        - joip_api_key: []
components:
  schemas:
    caption_rewrite_request:
      anyOf:
        - type: object
          additionalProperties: false
          properties:
            items:
              type: array
              items:
                type: object
                additionalProperties: false
                properties:
                  media_url:
                    type: string
                    format: uri
                    maxLength: 2048
                    pattern: ^https:\/\/
                  caption:
                    type: string
                    minLength: 1
                    maxLength: 4000
                    pattern: \S
                required:
                  - media_url
                  - caption
              minItems: 1
              maxItems: 10
            rewrite_mode:
              type: string
              enum:
                - improve
                - spicier
                - milder
                - different
            custom_instructions:
              type: string
              minLength: 1
              maxLength: 4000
              pattern: \S
          required:
            - items
            - rewrite_mode
        - type: object
          additionalProperties: false
          properties:
            items:
              type: array
              items:
                type: object
                additionalProperties: false
                properties:
                  media_url:
                    type: string
                    format: uri
                    maxLength: 2048
                    pattern: ^https:\/\/
                  caption:
                    type: string
                    minLength: 1
                    maxLength: 4000
                    pattern: \S
                required:
                  - media_url
                  - caption
              minItems: 1
              maxItems: 10
            rewrite_mode:
              const: custom
              type: string
            custom_instructions:
              type: string
              minLength: 1
              maxLength: 4000
              pattern: \S
          required:
            - items
            - rewrite_mode
            - custom_instructions
    job:
      type: object
      additionalProperties: false
      properties:
        id:
          type: string
          format: uuid
        type:
          type: string
          enum:
            - asset_import
            - caption_generation
            - caption_rewrite
            - censor
            - censor_ruin
            - babecock_generation
            - babecock_remix
            - undress_generation
            - session_reddit_import
            - session_manual_import
            - session_archive_import
        state:
          type: string
          enum:
            - queued
            - dispatching
            - submitted
            - polling
            - processing
            - needs_review
            - completed
            - partially_completed
            - failed
            - redacted
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        completed_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
        item_count:
          type: integer
          minimum: 0
        completed_item_count:
          type: integer
          minimum: 0
        failed_item_count:
          type: integer
          minimum: 0
        billing:
          type: object
          additionalProperties: false
          properties:
            reserved_credits:
              type: integer
              minimum: 0
            settled_credits:
              type: integer
              minimum: 0
            released_credits:
              type: integer
              minimum: 0
            currency:
              const: credits
              type: string
          required:
            - reserved_credits
            - settled_credits
            - released_credits
            - currency
          x-joip-cross-field-rules:
            - settled_credits + released_credits <= reserved_credits
        error:
          anyOf:
            - type: object
              additionalProperties: false
              properties:
                code:
                  type: string
                  pattern: ^[a-z][a-z0-9_]*$
                message:
                  type: string
                  minLength: 1
                  maxLength: 2000
              required:
                - code
                - message
            - type: 'null'
        items:
          type: array
          items:
            type: object
            additionalProperties: false
            properties:
              id:
                type: string
                format: uuid
              job_id:
                type: string
                format: uuid
              job_type:
                type: string
                enum:
                  - asset_import
                  - caption_generation
                  - caption_rewrite
                  - censor
                  - censor_ruin
                  - babecock_generation
                  - babecock_remix
                  - undress_generation
                  - session_reddit_import
                  - session_manual_import
                  - session_archive_import
              index:
                type: integer
                minimum: 0
              state:
                type: string
                enum:
                  - queued
                  - dispatching
                  - submitted
                  - polling
                  - processing
                  - needs_review
                  - completed
                  - failed
                  - redacted
              input_asset_ids:
                type: array
                items:
                  type: string
                  format: uuid
              output_asset_ids:
                type: array
                items:
                  type: string
                  format: uuid
              created_at:
                type: string
                format: date-time
              updated_at:
                type: string
                format: date-time
              completed_at:
                anyOf:
                  - type: string
                    format: date-time
                  - type: 'null'
              result:
                type: object
                additionalProperties: false
                properties:
                  type:
                    const: caption
                    type: string
                  source_asset_id:
                    type: string
                    format: uuid
                  caption_text:
                    type: string
                    minLength: 1
                    maxLength: 4000
                    pattern: \S
                required:
                  - type
                  - source_asset_id
                  - caption_text
              error:
                anyOf:
                  - type: object
                    additionalProperties: false
                    properties:
                      code:
                        type: string
                        pattern: ^[a-z][a-z0-9_]*$
                      message:
                        type: string
                        minLength: 1
                        maxLength: 2000
                    required:
                      - code
                      - message
                  - type: 'null'
            required:
              - id
              - job_id
              - job_type
              - index
              - state
              - input_asset_ids
              - output_asset_ids
              - created_at
              - updated_at
            x-joip-cross-field-rules:
              - >-
                terminal state requires completed_at; nonterminal state forbids
                completed_at
              - >-
                completed caption job type requires result.type = caption; every
                other job type or state forbids result
              - caption job types require output_asset_ids.length = 0
              - caption result source_asset_id must be one of input_asset_ids
      required:
        - id
        - type
        - state
        - created_at
        - updated_at
        - item_count
        - completed_item_count
        - failed_item_count
        - billing
      x-joip-cross-field-rules:
        - completed_item_count <= item_count
        - failed_item_count <= item_count
        - completed_item_count + failed_item_count <= item_count
        - >-
          terminal state requires completed_at; nonterminal state forbids
          completed_at
        - >-
          completed state requires completed_item_count = item_count and
          failed_item_count = 0
        - >-
          partially_completed state requires completed_item_count > 0,
          failed_item_count > 0, and their sum = item_count
        - >-
          failed state requires failed_item_count = item_count and
          completed_item_count = 0
        - >-
          redacted state requires completed_item_count + failed_item_count =
          item_count
        - >-
          terminal state requires settled_credits + released_credits =
          reserved_credits
        - >-
          items, when present, belong to this job (job_id = id, job_type =
          type), are in ascending index order, and number at most item_count
    problem_details:
      type: object
      additionalProperties: false
      properties:
        type:
          type: string
          format: uri
        title:
          type: string
          minLength: 1
          maxLength: 160
        status:
          type: integer
          minimum: 400
          maximum: 599
        detail:
          type: string
          minLength: 1
          maxLength: 2000
        instance:
          type: string
          maxLength: 500
        code:
          type: string
          pattern: ^[a-z][a-z0-9_]*$
        param:
          anyOf:
            - type: string
              pattern: ^[a-z][a-z0-9_.]*$
            - type: 'null'
          default: null
        request_id:
          type: string
          pattern: ^req_[a-z0-9]{16,64}$
      required:
        - type
        - title
        - status
        - detail
        - code
        - request_id
  securitySchemes:
    joip_api_key:
      type: http
      scheme: bearer
      bearerFormat: joip_live_...

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.