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

# Create Case

> Create a new case (workflow) with contacts and data schema.

Create a new case (workflow) with contacts and data schema.

<Note>
  Contacts are automatically created or linked if they already exist in the system based on their email address.
</Note>


## OpenAPI

````yaml POST /cases
openapi: 3.0.0
info:
  title: Penbox API
  version: '1.0'
  description: >-
    The Penbox API provides programmatic access to Penbox's form management,
    case management, and document processing capabilities. Authenticate using
    Bearer tokens created at https://app.penbox.io/workspace/settings/api
servers:
  - url: https://connect.penbox.io/v1
    description: Production
  - url: https://connect.aiboov.com/v1
    description: Staging
security:
  - BearerAuth: []
paths:
  /cases:
    post:
      summary: Create Case
      description: Create a new case (workflow) with contacts and data schema.
      operationId: create-case
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - title
              properties:
                title:
                  type: string
                  description: Case title
                reference:
                  type: string
                  description: Case reference. Use it to filter cases by reference.
                status:
                  type: string
                  description: Initial custom status
                template:
                  type: object
                  required:
                    - id
                  properties:
                    id:
                      type: string
                      format: uuid
                      description: Template UUID
                workspace:
                  type: object
                  required:
                    - id
                  properties:
                    id:
                      type: string
                      format: uuid
                      description: >-
                        Workspace UUID. Leave it empty to use the first
                        workspace from the token.
                owner:
                  type: object
                  properties:
                    email:
                      type: string
                      format: email
                      description: Owner email address
                contacts:
                  type: array
                  items:
                    $ref: '#/components/schemas/CaseContactInput'
                schema:
                  type: array
                  description: >-
                    Array of data fields from the schema. Leave it empty to use
                    the schema from the template. If you want to add new fields,
                    you can add them here.
                  items:
                    type: object
                    required:
                      - key
                    properties:
                      key:
                        type: string
                        description: Field key
                      type:
                        type: string
                        description: Field type
                      value:
                        description: Initial value
                      name:
                        type: string
                        description: Field display name
      responses:
        '200':
          description: Case created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CaseDetailed'
components:
  schemas:
    CaseContactInput:
      type: object
      required:
        - key
        - email
      properties:
        key:
          type: string
          description: >-
            Unique identifier for this contact within the case context. Use
            'main' for the main contact.
        name:
          type: string
          description: The role played by this contact within the case
        email:
          type: string
          format: email
          description: Contact's email address
        given_name:
          type: string
          description: First name
        family_name:
          type: string
          description: Last name
        phone:
          type: string
          description: Contact's phone number
    CaseDetailed:
      allOf:
        - $ref: '#/components/schemas/Case'
        - type: object
          properties:
            steps:
              type: array
              description: Array of step objects representing the case workflow
              items:
                type: object
                properties:
                  id:
                    type: string
                    description: Step identifier
                  title:
                    type: string
                    description: Step title
                  status:
                    type: string
                    description: Step status
                  data:
                    type: object
                    description: Step data
            schema:
              type: array
              description: Array of data fields with their current values
              items:
                type: object
                properties:
                  key:
                    type: string
                    description: Field key
                  type:
                    type: string
                    description: Field type
                  value:
                    description: Field value
                  name:
                    type: string
                    description: Field display name
    Case:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Case UUID
        created_at:
          type: string
          format: date-time
          description: Creation timestamp
        updated_at:
          type: string
          format: date-time
          description: Last update timestamp
        title:
          type: string
          description: Case title
        description:
          type: string
          nullable: true
          description: Case description
        locale:
          type: string
          nullable: true
          description: Language/locale code
        reference:
          type: string
          nullable: true
          description: Custom reference number
        status:
          type: string
          nullable: true
          description: Custom status value
        parent_status:
          type: string
          enum:
            - draft
            - pending
            - in_progress
            - closed
          description: Parent status
        waiting_for:
          type: string
          enum:
            - none
            - owner
            - contact
          description: Who the case is waiting for
        archived_at:
          type: string
          format: date-time
          nullable: true
          description: Timestamp when archived
        contacts:
          type: array
          description: Array of contact objects
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
                description: Contact UUID
              key:
                type: string
                description: Contact identifier
              name:
                type: string
                description: Contact role/name
              email:
                type: string
                format: email
                description: Contact email
              given_name:
                type: string
                description: First name
              family_name:
                type: string
                description: Last name
              phone:
                type: string
                description: Phone number
            additionalProperties: true
        template:
          type: string
          nullable: true
          description: Template reference
        owner:
          type: object
          nullable: true
          description: Case owner information
          properties:
            id:
              type: string
              format: uuid
            email:
              type: string
              format: email
            given_name:
              type: string
            family_name:
              type: string
      required:
        - id
        - title
        - parent_status
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: token
      description: >-
        API token (starts with pnbx_). Create at
        https://app.penbox.io/workspace/settings/api. Include as: Authorization:
        Bearer {token}

````