Cloudflare Workers API

Cloudflare Workers allows developers to deploy serverless code to Cloudflare's global network. The Workers API provides endpoints for managing worker scripts, versions, deployments, and configuration including bindings, routes, and custom domains.

OpenAPI Specification

cloudflare-workers-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: Cloudflare Workers API
  description: >-
    Cloudflare Workers allows developers to deploy serverless code to
    Cloudflare's global network. The Workers API provides endpoints for
    managing worker scripts, versions, deployments, routes, custom domains,
    secrets, cron triggers, and configuration including bindings.
  version: '4.0'
  contact:
    name: Cloudflare Support
    url: https://support.cloudflare.com/
  termsOfService: https://www.cloudflare.com/terms/
externalDocs:
  description: Cloudflare Workers API Documentation
  url: https://developers.cloudflare.com/api/resources/workers/
servers:
- url: https://api.cloudflare.com/client/v4
  description: Cloudflare API v4 Production Server
tags:
- name: Configuration
  description: >-
    Manage Worker script settings, cron triggers, and account settings.
- name: Deployments
  description: >-
    Manage deployments that direct traffic to specific Worker versions.
- name: Domains
  description: >-
    Attach and detach custom domains to Worker scripts.
- name: Routes
  description: >-
    Map URL patterns to Worker scripts within a zone.
- name: Scripts
  description: >-
    Upload, download, and manage Worker scripts by name.
- name: Secrets
  description: >-
    Manage encrypted environment variables for Worker scripts.
- name: Versions
  description: >-
    Manage immutable snapshots of Worker code and configuration.
- name: Workers
  description: >-
    Manage Worker resources including creating, updating, and deleting Workers.
security:
- bearerAuth: []
paths:
  /accounts/{account_id}/workers/workers:
    get:
      operationId: listWorkers
      summary: Cloudflare List Workers
      description: >-
        Returns a paginated list of all Workers for an account.
      tags:
      - Workers
      parameters:
      - $ref: '#/components/parameters/AccountId'
      responses:
        '200':
          description: Successful response with list of Workers.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkerListResponse'
              examples:
                Listworkers200Example:
                  summary: Default listWorkers 200 response
                  x-microcks-default: true
                  value:
                    result:
                    - id: abc123
                      name: Example Title
                      created_on: '2026-01-15T10:30:00Z'
                      modified_on: '2026-01-15T10:30:00Z'
                    success: true
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    post:
      operationId: createWorker
      summary: Cloudflare Create Worker
      description: >-
        Establish a new Worker with the provided configuration.
      tags:
      - Workers
      parameters:
      - $ref: '#/components/parameters/AccountId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkerInput'
            examples:
              CreateworkerRequestExample:
                summary: Default createWorker request
                x-microcks-default: true
                value:
                  name: Example Title
                  main_module: example_value
      responses:
        '200':
          description: Worker created successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkerResponse'
              examples:
                Createworker200Example:
                  summary: Default createWorker 200 response
                  x-microcks-default: true
                  value:
                    result:
                      id: abc123
                      name: Example Title
                      created_on: '2026-01-15T10:30:00Z'
                      modified_on: '2026-01-15T10:30:00Z'
                    success: true
                    errors:
                    - {}
                    messages:
                    - {}
        '400':
          description: Bad request.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /accounts/{account_id}/workers/workers/{worker_id}:
    get:
      operationId: getWorker
      summary: Cloudflare Get Worker
      description: >-
        Retrieve details of a specific Worker by its identifier.
      tags:
      - Workers
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/WorkerId'
      responses:
        '200':
          description: Worker details retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/WorkerResponse'
              examples:
                Getworker200Example:
                  summary: Default getWorker 200 response
                  x-microcks-default: true
                  value:
                    result:
                      id: abc123
                      name: Example Title
                      created_on: '2026-01-15T10:30:00Z'
                      modified_on: '2026-01-15T10:30:00Z'
                    success: true
                    errors:
                    - {}
                    messages:
                    - {}
        '401':
          description: Unauthorized.
        '404':
          description: Worker not found.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    put:
      operationId: replaceWorker
      summary: Cloudflare Replace Worker
      description: >-
        Complete replacement of Worker properties.
      tags:
      - Workers
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/WorkerId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkerInput'
            examples:
              ReplaceworkerRequestExample:
                summary: Default replaceWorker request
                x-microcks-default: true
                value:
                  name: Example Title
                  main_module: example_value
      responses:
        '200':
          description: Worker replaced successfully.
        '401':
          description: Unauthorized.
        '404':
          description: Worker not found.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    patch:
      operationId: editWorker
      summary: Cloudflare Edit Worker
      description: >-
        Partial update preserving unchanged fields.
      tags:
      - Workers
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/WorkerId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/WorkerInput'
            examples:
              EditworkerRequestExample:
                summary: Default editWorker request
                x-microcks-default: true
                value:
                  name: Example Title
                  main_module: example_value
      responses:
        '200':
          description: Worker updated successfully.
        '401':
          description: Unauthorized.
        '404':
          description: Worker not found.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    delete:
      operationId: deleteWorker
      summary: Cloudflare Delete Worker
      description: >-
        Remove a Worker and all associated resources.
      tags:
      - Workers
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/WorkerId'
      responses:
        '200':
          description: Worker deleted successfully.
        '401':
          description: Unauthorized.
        '404':
          description: Worker not found.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /accounts/{account_id}/workers/scripts:
    get:
      operationId: listScripts
      summary: Cloudflare List Worker Scripts
      description: >-
        Retrieve a list of all Worker scripts for the account.
      tags:
      - Scripts
      parameters:
      - $ref: '#/components/parameters/AccountId'
      responses:
        '200':
          description: List of Worker scripts.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ScriptListResponse'
              examples:
                Listscripts200Example:
                  summary: Default listScripts 200 response
                  x-microcks-default: true
                  value:
                    result:
                    - id: abc123
                      tag: example_value
                      etag: example_value
                      created_on: '2026-01-15T10:30:00Z'
                      modified_on: '2026-01-15T10:30:00Z'
                    success: true
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /accounts/{account_id}/workers/scripts/{script_name}:
    get:
      operationId: downloadScript
      summary: Cloudflare Download Worker Script
      description: >-
        Download a Worker script by name. Returns the script content.
      tags:
      - Scripts
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: Worker script content.
        '401':
          description: Unauthorized.
        '404':
          description: Script not found.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    put:
      operationId: uploadScript
      summary: Cloudflare Upload Worker Script
      description: >-
        Upload or update a Worker script by name using multipart form data or
        JSON with base64-encoded content.
      tags:
      - Scripts
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: Script uploaded successfully.
        '400':
          description: Bad request.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    delete:
      operationId: deleteScript
      summary: Cloudflare Delete Worker Script
      description: >-
        Delete a Worker script by name.
      tags:
      - Scripts
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: Script deleted successfully.
        '401':
          description: Unauthorized.
        '404':
          description: Script not found.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /accounts/{account_id}/workers/workers/{worker_id}/versions:
    get:
      operationId: listVersions
      summary: Cloudflare List Worker Versions
      description: >-
        Retrieve all immutable versions of a Worker's code and configuration.
      tags:
      - Versions
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/WorkerId'
      responses:
        '200':
          description: List of Worker versions.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    post:
      operationId: createVersion
      summary: Cloudflare Create Worker Version
      description: >-
        Create a new immutable snapshot of Worker code and configuration.
      tags:
      - Versions
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/WorkerId'
      responses:
        '200':
          description: Version created successfully.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /accounts/{account_id}/workers/scripts/{script_name}/deployments:
    get:
      operationId: listDeployments
      summary: Cloudflare List Deployments
      description: >-
        List all deployments for a Worker script.
      tags:
      - Deployments
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: List of deployments.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    post:
      operationId: createDeployment
      summary: Cloudflare Create Deployment
      description: >-
        Create a new deployment directing traffic to a specific Worker version.
      tags:
      - Deployments
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: Deployment created successfully.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /zones/{zone_id}/workers/routes:
    get:
      operationId: listRoutes
      summary: Cloudflare List Worker Routes
      description: >-
        Retrieve all routes mapping URL patterns to Worker scripts for a zone.
      tags:
      - Routes
      parameters:
      - $ref: '#/components/parameters/ZoneId'
      responses:
        '200':
          description: List of Worker routes.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RouteListResponse'
              examples:
                Listroutes200Example:
                  summary: Default listRoutes 200 response
                  x-microcks-default: true
                  value:
                    result:
                    - id: abc123
                      pattern: example_value
                      script: example_value
                    success: true
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    post:
      operationId: createRoute
      summary: Cloudflare Create Worker Route
      description: >-
        Map a URL pattern to a Worker script within the zone.
      tags:
      - Routes
      parameters:
      - $ref: '#/components/parameters/ZoneId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RouteInput'
            examples:
              CreaterouteRequestExample:
                summary: Default createRoute request
                x-microcks-default: true
                value:
                  pattern: example_value
                  script: example_value
      responses:
        '200':
          description: Route created successfully.
        '400':
          description: Bad request.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /zones/{zone_id}/workers/routes/{route_id}:
    get:
      operationId: getRoute
      summary: Cloudflare Get Worker Route
      description: >-
        Retrieve details of a specific Worker route.
      tags:
      - Routes
      parameters:
      - $ref: '#/components/parameters/ZoneId'
      - $ref: '#/components/parameters/RouteId'
      responses:
        '200':
          description: Route details.
        '401':
          description: Unauthorized.
        '404':
          description: Route not found.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    put:
      operationId: updateRoute
      summary: Cloudflare Update Worker Route
      description: >-
        Update the pattern or script assignment for a Worker route.
      tags:
      - Routes
      parameters:
      - $ref: '#/components/parameters/ZoneId'
      - $ref: '#/components/parameters/RouteId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RouteInput'
            examples:
              UpdaterouteRequestExample:
                summary: Default updateRoute request
                x-microcks-default: true
                value:
                  pattern: example_value
                  script: example_value
      responses:
        '200':
          description: Route updated successfully.
        '401':
          description: Unauthorized.
        '404':
          description: Route not found.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    delete:
      operationId: deleteRoute
      summary: Cloudflare Delete Worker Route
      description: >-
        Remove a Worker route from the zone.
      tags:
      - Routes
      parameters:
      - $ref: '#/components/parameters/ZoneId'
      - $ref: '#/components/parameters/RouteId'
      responses:
        '200':
          description: Route deleted successfully.
        '401':
          description: Unauthorized.
        '404':
          description: Route not found.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /accounts/{account_id}/workers/domains:
    get:
      operationId: listDomains
      summary: Cloudflare List Worker Domains
      description: >-
        Retrieve all custom domains attached to Worker scripts.
      tags:
      - Domains
      parameters:
      - $ref: '#/components/parameters/AccountId'
      responses:
        '200':
          description: List of Worker domains.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    put:
      operationId: attachDomain
      summary: Cloudflare Attach Custom Domain
      description: >-
        Attach a custom domain to a Worker script.
      tags:
      - Domains
      parameters:
      - $ref: '#/components/parameters/AccountId'
      responses:
        '200':
          description: Domain attached successfully.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /accounts/{account_id}/workers/scripts/{script_name}/secrets:
    get:
      operationId: listSecrets
      summary: Cloudflare List Worker Secrets
      description: >-
        List all secrets for a Worker script. Secret values are not returned.
      tags:
      - Secrets
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: List of secret names.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    put:
      operationId: addSecret
      summary: Cloudflare Add Worker Secret
      description: >-
        Add or update an encrypted secret for a Worker script.
      tags:
      - Secrets
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - name
              - text
              - type
              properties:
                name:
                  type: string
                  description: The name of the secret.
                text:
                  type: string
                  description: The value of the secret.
                type:
                  type: string
                  enum:
                  - secret_text
                  description: The type of the secret binding.
            examples:
              AddsecretRequestExample:
                summary: Default addSecret request
                x-microcks-default: true
                value:
                  name: Example Title
                  text: example_value
                  type: secret_text
      responses:
        '200':
          description: Secret added successfully.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /accounts/{account_id}/workers/scripts/{script_name}/schedules:
    get:
      operationId: getCronTriggers
      summary: Cloudflare Get Cron Triggers
      description: >-
        Retrieve the cron trigger schedules for a Worker script.
      tags:
      - Configuration
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: Cron trigger schedules.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    put:
      operationId: updateCronTriggers
      summary: Cloudflare Update Cron Triggers
      description: >-
        Set the cron trigger schedules for a Worker script.
      tags:
      - Configuration
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: Cron triggers updated successfully.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
  /accounts/{account_id}/workers/scripts/{script_name}/settings:
    get:
      operationId: getScriptSettings
      summary: Cloudflare Get Script Settings
      description: >-
        Retrieve configuration settings for a Worker script including bindings
        and compatibility settings.
      tags:
      - Configuration
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: Script settings.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
    patch:
      operationId: updateScriptSettings
      summary: Cloudflare Update Script Settings
      description: >-
        Update configuration settings for a Worker script.
      tags:
      - Configuration
      parameters:
      - $ref: '#/components/parameters/AccountId'
      - $ref: '#/components/parameters/ScriptName'
      responses:
        '200':
          description: Settings updated successfully.
        '401':
          description: Unauthorized.
      x-microcks-operation:
        delay: 0
        dispatcher: FALLBACK
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        API token authentication with Workers permissions.
  parameters:
    AccountId:
      name: account_id
      in: path
      required: true
      description: The unique identifier of the Cloudflare account.
      schema:
        type: string
    WorkerId:
      name: worker_id
      in: path
      required: true
      description: The unique identifier of the Worker.
      schema:
        type: string
    ScriptName:
      name: script_name
      in: path
      required: true
      description: The name of the Worker script.
      schema:
        type: string
    ZoneId:
      name: zone_id
      in: path
      required: true
      description: The unique identifier of the zone.
      schema:
        type: string
    RouteId:
      name: route_id
      in: path
      required: true
      description: The unique identifier of the route.
      schema:
        type: string
  schemas:
    WorkerInput:
      type: object
      properties:
        name:
          type: string
          description: The name of the Worker.
          example: Example Title
        main_module:
          type: string
          description: The entry point module for the Worker.
          example: example_value
    WorkerResponse:
      type: object
      properties:
        result:
          type: object
          properties:
            id:
              type: string
              description: The unique Worker identifier.
            name:
              type: string
              description: The Worker name.
            created_on:
              type: string
              format: date-time
              description: When the Worker was created.
            modified_on:
              type: string
              format: date-time
              description: When the Worker was last modified.
          example: example_value
        success:
          type: boolean
          example: true
        errors:
          type: array
          items:
            type: object
          example: []
        messages:
          type: array
          items:
            type: object
          example: []
    WorkerListResponse:
      type: object
      properties:
        result:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              name:
                type: string
              created_on:
                type: string
                format: date-time
              modified_on:
                type: string
                format: date-time
          example: []
        success:
          type: boolean
          example: true
    ScriptListResponse:
      type: object
      properties:
        result:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                description: The script identifier.
              tag:
                type: string
                description: The unique tag for the script.
              etag:
                type: string
                description: The ETag of the script.
              created_on:
                type: string
                format: date-time
              modified_on:
                type: string
                format: date-time
          example: []
        success:
          type: boolean
          example: true
    RouteInput:
      type: object
      required:
      - pattern
      properties:
        pattern:
          type: string
          description: The URL pattern for the route, e.g. example.com/*.
          example: example_value
        script:
          type: string
          description: The name of the Worker script to invoke.
          example: example_value
    RouteListResponse:
      type: object
      properties:
        result:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
              pattern:
                type: string
              script:
                type: string
          example: []
        success:
          type: boolean
          example: true