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

# Apply a batch of work items

> Creates, updates, or restores up to 100 work items by external ID in one request.



## OpenAPI

````yaml rulebase_api2_public_openapi.json POST /v1/work_items/batch
openapi: 3.1.0
info:
  title: Rulebase API v2
  version: 2.0.0
  description: Read data from Rulebase using an organization API key.
servers:
  - url: https://api2.rulebase.co
    description: US
  - url: https://eu.api2.rulebase.co
    description: EU
security: []
paths:
  /v1/work_items/batch:
    post:
      tags:
        - Work items
      summary: Apply a batch of work items
      description: >-
        Create, update, or restore up to 100 work items by external ID. Results
        preserve input order; a failed item does not roll back the others, and
        omitted work items are never deleted. Set `dry_run` to preview the
        outcome without writing.
      operationId: applyWorkItems
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                work_items:
                  type: array
                  items:
                    type: object
                    properties:
                      external_id:
                        type: string
                        minLength: 1
                      agent_email:
                        type: string
                        format: email
                      agent_name:
                        type: string
                        minLength: 1
                      agent_external_id:
                        type: string
                        minLength: 1
                      type:
                        type: string
                        minLength: 1
                      status:
                        type: string
                        enum:
                          - pending
                          - in_progress
                          - completed
                          - cancelled
                      completed_at:
                        type: string
                        nullable: true
                        format: date-time
                      custom_attributes:
                        type: object
                        additionalProperties:
                          nullable: true
                        default: {}
                      events:
                        type: array
                        items:
                          type: object
                          properties:
                            external_id:
                              type: string
                              minLength: 1
                            actor_email:
                              type: string
                              format: email
                            actor_name:
                              type: string
                              minLength: 1
                            actor_external_id:
                              type: string
                              minLength: 1
                            content:
                              type: string
                              nullable: true
                            occurred_at:
                              type: string
                              nullable: true
                              format: date-time
                          required:
                            - external_id
                        default: []
                    required:
                      - external_id
                  minItems: 1
                  maxItems: 100
                dry_run:
                  type: boolean
                  default: false
              required:
                - work_items
      responses:
        '200':
          description: Batch applied
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      dry_run:
                        type: boolean
                      summary:
                        type: object
                        properties:
                          total:
                            type: integer
                          created:
                            type: integer
                          updated:
                            type: integer
                          unchanged:
                            type: integer
                          restored:
                            type: integer
                          error:
                            type: integer
                        required:
                          - total
                          - created
                          - updated
                          - unchanged
                          - restored
                          - error
                      results:
                        type: array
                        items:
                          type: object
                          properties:
                            index:
                              type: integer
                            external_id:
                              type: string
                            status:
                              type: string
                              enum:
                                - created
                                - updated
                                - unchanged
                                - restored
                                - error
                            data:
                              type: object
                              nullable: true
                              properties:
                                id:
                                  type: string
                                  format: uuid
                                external_id:
                                  type: string
                                agent:
                                  type: object
                                  properties:
                                    id:
                                      type: string
                                      nullable: true
                                    name:
                                      type: string
                                      nullable: true
                                    email:
                                      type: string
                                      nullable: true
                                    external_id:
                                      type: string
                                      nullable: true
                                    avatar_url:
                                      type: string
                                      nullable: true
                                  required:
                                    - id
                                    - name
                                    - email
                                    - external_id
                                    - avatar_url
                                agents:
                                  type: array
                                  items:
                                    type: object
                                    properties:
                                      id:
                                        type: string
                                        nullable: true
                                      name:
                                        type: string
                                        nullable: true
                                      email:
                                        type: string
                                        nullable: true
                                      external_id:
                                        type: string
                                        nullable: true
                                      avatar_url:
                                        type: string
                                        nullable: true
                                    required:
                                      - id
                                      - name
                                      - email
                                      - external_id
                                      - avatar_url
                                type:
                                  type: string
                                status:
                                  type: string
                                  enum:
                                    - pending
                                    - in_progress
                                    - completed
                                    - cancelled
                                short_description:
                                  type: string
                                  nullable: true
                                description:
                                  type: string
                                  nullable: true
                                completed_at:
                                  type: string
                                  nullable: true
                                  format: date-time
                                custom_attributes:
                                  type: object
                                  additionalProperties:
                                    nullable: true
                                created_at:
                                  type: string
                                  format: date-time
                                updated_at:
                                  type: string
                                  format: date-time
                                qa_score:
                                  type: number
                                  nullable: true
                                  minimum: 0
                                  maximum: 1
                              required:
                                - id
                                - external_id
                                - agent
                                - agents
                                - type
                                - status
                                - short_description
                                - description
                                - completed_at
                                - custom_attributes
                                - created_at
                                - updated_at
                                - qa_score
                            error:
                              type: string
                              nullable: true
                          required:
                            - index
                            - external_id
                            - status
                            - data
                            - error
                    required:
                      - dry_run
                      - summary
                      - results
                required:
                  - data
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
        '422':
          description: Invalid work item
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
        '429':
          description: >-
            Rate limit exceeded. Retry after the number of seconds in the
            Retry-After header.
          headers:
            Retry-After:
              schema:
                type: string
              description: Seconds to wait before retrying
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                required:
                  - error
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Rulebase organization API key

````