:::open-api-operation
---
operation:
  kind: operation
  method: post
  path: /batches
  operationId: runBatch
  summary: Run a batch
  deprecated: false
  tags:
    - Batches
  requestBody:
    required: true
    content:
      - type: application/json
        schema:
          types:
            - object
          properties:
            - name: instructions
              required: true
              schema:
                types:
                  - array
                constraints:
                  minItems: 1
                  maxItems: 50
                items:
                  name: Instruction
                  ref: "#/components/schemas/Instruction"
                  oneOf:
                    - name: RelabelInstruction
                      ref: "#/components/schemas/RelabelInstruction"
                      types:
                        - object
                      properties:
                        - name: op
                          required: true
                          schema:
                            const: relabel
                        - name: consignmentId
                          required: true
                          schema:
                            types:
                              - string
                            format: uuid
                        - name: reference
                          required: true
                          schema:
                            types:
                              - string
                    - name: RetagInstruction
                      ref: "#/components/schemas/RetagInstruction"
                      types:
                        - object
                      properties:
                        - name: op
                          required: true
                          schema:
                            const: retag
                        - name: consignmentId
                          required: true
                          schema:
                            types:
                              - string
                            format: uuid
                        - name: tags
                          required: true
                          schema:
                            types:
                              - array
                            items:
                              types:
                                - string
                  discriminator:
                    propertyName: op
                    mapping:
                      relabel: "#/components/schemas/RelabelInstruction"
                      retag: "#/components/schemas/RetagInstruction"
  responses:
    - status: "200"
      description: What each instruction did.
      content:
        - type: application/json
          schema:
            types:
              - array
            items:
              oneOf:
                - types:
                    - object
                  properties:
                    - name: done
                      required: false
                      schema:
                        types:
                          - boolean
                - name: Problem
                  ref: "#/components/schemas/Problem"
                  types:
                    - object
                  properties:
                    - name: title
                      required: true
                      schema:
                        types:
                          - string
                        description: A short, human-readable summary.
                    - name: status
                      required: true
                      schema:
                        types:
                          - integer
                        constraints:
                          minimum: 400
                          maximum: 599
                    - name: detail
                      required: false
                      schema:
                        types:
                          - string
                          - "null"
servers:
  - url: https://api.example.org/{stage}
    description: The invented production host.
    variables:
      - name: stage
        default: v3
        enum:
          - v1
          - v2
          - v3
        description: Which line of the API to talk to.
  - url: http://localhost:8080
    description: A local process, for trying things out.
security: []
securitySchemes:
  - key: apiKey
    type: apiKey
    description: A key from the account page.
    name: X-Api-Key
    in: header
  - key: bearer
    type: http
    description: A token obtained from the authorisation server.
    scheme: bearer
    example: demo-token
    bearerFormat: JWT
  - key: oauth
    type: oauth2
    description: For applications acting on someone else's behalf.
    flows:
      - name: authorizationCode
        authorizationUrl: https://auth.example.org/authorize
        tokenUrl: https://auth.example.org/token
        scopes:
          - name: consignments:read
            description: Read consignments
          - name: consignments:write
            description: Book and change consignments
---
Takes a list of instructions and applies them in order. This endpoint
needs no authentication, which is why it takes nothing destructive.
:::