> ## 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 Contact

> Create a contact in a workspace

Create a contact in a workspace. Send at least one of `email`, `phone` or `internal_ref`. Use `internal_ref` for the contact's id in your CRM: you can then find it again with [List Contacts](https://docs.penbox.io/api-reference/contacts/list-contacts.md).

Creating a contact sends it nothing. Penbox writes to a contact only when your team sends it a form or an email.

## Retries

Posting a contact identical to one that already exists (same value on every field you send) returns that contact with a `200` instead of creating a duplicate. A `201` means the contact was created. Emails are trimmed and lowercased first.

A contact that differs on one field, for example the same email with another `internal_ref`, is a new contact. Look it up first, then [update it](https://docs.penbox.io/api-reference/contacts/update-contact.md).

> [!WARNING]
>
> `workspace.id` is always explicit, never inferred from the token. A token that does not cover the workspace returns a `404`.

```bash theme={null} theme={null}
curl --request POST \
  --url https://connect.penbox.io/v1/contacts \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "workspace": { "id": "16b47f46-3358-4217-af17-102b6e6d2e60" },
    "email": "jan.peeters@example.com",
    "given_name": "Jan",
    "family_name": "Peeters",
    "company_name": "Peeters SRL",
    "internal_ref": "AP-1042"
  }'
```


## OpenAPI

````yaml POST /contacts
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
security:
  - BearerAuth: []
paths:
  /contacts:
    post:
      summary: Create Contact
      description: >-
        Create a contact in a workspace. At least one of `email`, `phone` or
        `internal_ref` is required.


        Posting a contact identical to an existing one (same value on every
        field sent) returns that contact with a `200` instead of creating a
        duplicate.
      operationId: create-contact
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - workspace
              properties:
                workspace:
                  type: object
                  required:
                    - id
                  description: >-
                    Workspace to create the contact in. Always explicit, never
                    inferred from the token.
                  properties:
                    id:
                      type: string
                      format: uuid
                email:
                  type: string
                  format: email
                  description: Email address. Trimmed and lowercased.
                given_name:
                  type: string
                  maxLength: 100
                  description: First name
                family_name:
                  type: string
                  maxLength: 100
                  description: Last name
                company_name:
                  type: string
                  maxLength: 255
                  description: Company the contact belongs to
                internal_ref:
                  type: string
                  maxLength: 255
                  description: >-
                    Your own reference for the contact, such as its id in your
                    CRM
                phone:
                  type: string
                  maxLength: 50
                  description: Phone number, international format preferred
                  example: '+32470123456'
                locale:
                  type: string
                  maxLength: 10
                  description: Language Penbox addresses the contact in
                  example: fr
      responses:
        '200':
          description: An identical contact already exists, and is returned unchanged
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contact'
        '201':
          description: The contact was created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Contact'
        '400':
          description: Invalid body, or none of `email`, `phone`, `internal_ref`
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Your key does not cover the workspace
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    Contact:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Contact UUID
        created_at:
          type: string
          format: date-time
          description: Creation timestamp
        updated_at:
          type: string
          format: date-time
          description: Last update timestamp
        email:
          type: string
          format: email
          description: Email address. Trimmed and lowercased.
          nullable: true
        given_name:
          type: string
          nullable: true
          description: First name
        family_name:
          type: string
          nullable: true
          description: Last name
        company_name:
          type: string
          description: Company the contact belongs to
          nullable: true
        internal_ref:
          type: string
          description: Your own reference for the contact, such as its id in your CRM
          nullable: true
        phone:
          type: string
          description: Phone number, international format preferred
          nullable: true
        locale:
          type: string
          description: Language Penbox addresses the contact in
          nullable: true
        workspace:
          type: object
          description: Workspace the contact belongs to
          properties:
            id:
              type: string
              format: uuid
    Error:
      type: object
      properties:
        errors:
          type: array
          items:
            type: object
            properties:
              status:
                type: string
              title:
                type: string
              detail:
                type: string
              source:
                type: object
                properties:
                  pointer:
                    type: string
  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}

````

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