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

# Bulk create contacts

> POST /dn/contacts/bulk adds up to 100 contacts to your address book in one request.

Add up to 100 contacts in one request by sending them as a list in `data`. Each contact is checked and saved the same way as [Create a contact](https://detrack.mintlify.site/api-reference/contacts/create.md), so each needs `deliver_to_collect_from` or `company_name`, and an `address` unless you send `address_1`, `address_2`, or `address_3`.

When every contact is valid, the API returns `201` with the new contacts in the order you sent them. When some aren't, the valid ones are still saved, and the API returns `422` with the code `validation_failed`. Its `errors` names each rejected contact by its `index` in your list, counting from 0, and its `data` lists the contacts that were created. Resend only the rejected contacts, or the others are saved twice.

Nothing is saved, and the API returns `422`, if `data`:

* isn't a list, is empty, or has an entry that isn't an object (`invalid_data`)
* has more than 100 contacts (`too_many_contacts`). The extra contacts aren't skipped, as they are by [Bulk create jobs](https://detrack.mintlify.site/api-reference/jobs/bulk-create.md), so split a longer list into several requests.

If a contact's `groups` or `items` can't be read, for example `groups` is a string instead of a list, that contact is rejected with `"field": null` and the code "groups or items can't be read", and the others are still saved.

Detrack doesn't check for duplicates, so a contact you send twice is saved twice.


## OpenAPI

````yaml POST /dn/contacts/bulk
openapi: 3.0.3
info:
  title: Detrack REST API v2
  version: '2.0'
  description: >-
    Detrack REST API v2. Checked against detrack-webapp origin/main (production)
    on 2026-09-29: dn_jobs.rb @ d246ad006, dn_depots.rb @ 2a5f387, dn_routes.rb
    @ 50a73a9, app_helper.rb @ d745ad2, dn_jobs_helper.rb @ d296e30,
    job_decorator.rb @ 3041da7, run_location_decorator.rb @ 0f0274d,
    vehicle_route_plan_decorator.rb and tsp_route_decorator.rb @ 7d1f3ef,
    data_export.rb @ ed4e135. Vehicle check submissions checked against
    origin/main on 2026-11-03: dn_vehicle_checklist_submissions.rb @ 3071523d1,
    vehicle_checklist_submission_decorator.rb @ f4002c957,
    vehicle_checklist_submission.rb @ b80aea03c,
    vehicle_checklist_submission_rules.rb @ e55194ed7. Contacts checked against
    origin/main on 2026-11-04: dn_contacts.rb, contacts_helper.rb and contact.rb
    @ a1b3694a0, contact_decorator.rb @ a51f1eab7.
servers:
  - url: https://app.detrack.com/api/v2
security:
  - apiKey: []
tags:
  - name: Jobs
    description: Deliveries and collections.
  - name: Depots
    description: Saved warehouse and pickup locations.
  - name: Contacts
    description: Your address book of saved recipients.
  - name: Routes
    description: Optimized multi-stop plans across vehicles.
  - name: Vehicle checks
    description: >-
      Checklists your drivers submit for a vehicle, such as start-of-day and
      end-of-day checks.
paths:
  /dn/contacts/bulk:
    post:
      tags:
        - Contacts
      summary: Bulk create contacts
      description: >-
        Creates up to 100 contacts. Each is checked and saved as [Create a
        contact](/api-reference/contacts/create) does, so one invalid contact
        doesn't stop the rest.
      operationId: bulkCreateContacts
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - data
              properties:
                data:
                  type: array
                  minItems: 1
                  maxItems: 100
                  description: 1 to 100 contacts. Send more than 100 and nothing is saved.
                  items:
                    $ref: '#/components/schemas/ContactInput'
            example:
              data:
                - deliver_to_collect_from: James Li
                  address: 61 Kaki Bukit Ave 1, Singapore 417943
                  phone_number: '65432178'
                - company_name: Kaki Bukit Hardware
                  address: 10 Ubi Crescent, Singapore 408564
      responses:
        '201':
          description: >-
            Every contact was created. They're listed in the order you sent
            them.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      $ref: '#/components/schemas/Contact'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '422':
          description: >-
            Some contacts failed validation (`validation_failed`). The valid
            ones are still saved and listed in `data`, and `errors` names each
            failed contact by its `index`. Nothing is saved when `data` isn't a
            list, is empty, or has an entry that isn't an object
            (`invalid_data`), or has more than 100 contacts
            (`too_many_contacts`); those responses have only `code` and
            `message`.
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    example: validation_failed
                  message:
                    type: string
                    example: Validation failed
                  errors:
                    type: array
                    description: >-
                      One entry per failed contact. Only for
                      `validation_failed`.
                    items:
                      type: object
                      properties:
                        index:
                          type: integer
                          example: 1
                          description: The contact's position in `data`, counting from 0.
                        errors:
                          type: array
                          description: >-
                            The same errors [Create a
                            contact](/api-reference/contacts/create) returns for
                            that contact.
                          items:
                            type: object
                            properties:
                              field:
                                type: string
                                nullable: true
                                example: address
                                description: >-
                                  The field to fix. `null` when the contact's
                                  `groups` or `items` can't be read.
                              codes:
                                type: array
                                items:
                                  type: string
                                example:
                                  - cannot be blank
                  data:
                    type: array
                    description: >-
                      The contacts that were created, in the order you sent
                      them. Only for `validation_failed`, where it's always
                      present, even when empty.
                    items:
                      $ref: '#/components/schemas/Contact'
        default:
          $ref: '#/components/responses/ServerError'
components:
  schemas:
    ContactInput:
      type: object
      description: >-
        Contact fields you can send. On update, send only the fields you want to
        change. A contact needs `deliver_to_collect_from` or `company_name`.
      properties:
        deliver_to_collect_from:
          type: string
          description: Recipient's name. Required unless you send `company_name`.
          example: James Li
        company_name:
          type: string
          description: Required unless you send `deliver_to_collect_from`.
        last_name:
          type: string
        address:
          type: string
          description: >-
            Full address. Required unless you send `address_1`, `address_2`, or
            `address_3`. On create, Detrack adds any `address_1` to `address_3`,
            `city`, `state`, and `postal_code` you send to the end of `address`,
            so send the full address here or the parts, not both.
          example: 61 Kaki Bukit Ave 1, Singapore 417943
        address_1:
          type: string
          description: Address line 1.
        address_2:
          type: string
          description: Address line 2.
        address_3:
          type: string
          description: Address line 3.
        postal_code:
          type: string
        city:
          type: string
        state:
          type: string
        country:
          type: string
        address_lat:
          type: number
        address_lng:
          type: number
        phone_number:
          type: string
          example: '65432178'
        fax_number:
          type: string
        notify_email:
          type: string
          example: test@example.com
        job_time:
          type: string
        customer:
          type: string
        zone:
          type: string
        instructions:
          type: string
        boxes:
          type: string
        cubic_meters:
          type: number
        cartons:
          type: integer
        pieces:
          type: integer
        envelopes:
          type: integer
        pallets:
          type: integer
        remarks:
          type: string
        account_number:
          type: string
        sales_person:
          type: string
        sender_phone_number:
          type: string
        pick_up_from:
          type: string
        pick_up_time:
          type: string
        pick_up_address:
          type: string
        pick_up_address_1:
          type: string
        pick_up_address_2:
          type: string
        pick_up_address_3:
          type: string
        pick_up_city:
          type: string
        pick_up_state:
          type: string
        pick_up_country:
          type: string
        pick_up_postal_code:
          type: string
        pick_up_zone:
          type: string
        pick_up_lat:
          type: number
        pick_up_lng:
          type: number
        groups:
          type: array
          description: >-
            Groups the contact belongs to, by `id`. If your API key's user only
            has access to some groups, a new contact must be in at least one of
            them. If the user has exactly one group and you don't send `groups`,
            the contact goes in that group.
          items:
            type: object
            required:
              - id
            properties:
              id:
                type: string
                example: 5e8b2f1a29e804cae4fe0a11
        items:
          type: array
          description: >-
            Saved line items. On update, the items you send are added to or
            change the contact's items; they don't replace the list.
          items:
            $ref: '#/components/schemas/ContactItemInput'
    Contact:
      type: object
      description: >-
        A saved recipient. Empty fields are `null`. The pick-up fields
        (`pick_up_*`) are returned only if your account uses point-to-point
        jobs.
      properties:
        id:
          type: string
          readOnly: true
          example: 65263b0c29e804cae4fedd76
        deliver_to_collect_from:
          type: string
          nullable: true
          description: Recipient's name.
          example: James Li
        last_name:
          type: string
          nullable: true
        job_time:
          type: string
          nullable: true
        customer:
          type: string
          nullable: true
        company_name:
          type: string
          nullable: true
          example: Detrack
        address:
          type: string
          nullable: true
          example: 61 Kaki Bukit Ave 1, Singapore 417943
        postal_code:
          type: string
          nullable: true
        address_1:
          type: string
          nullable: true
        address_2:
          type: string
          nullable: true
        address_3:
          type: string
          nullable: true
        city:
          type: string
          nullable: true
        state:
          type: string
          nullable: true
        country:
          type: string
          nullable: true
        address_lat:
          type: number
          nullable: true
        address_lng:
          type: number
          nullable: true
        phone_number:
          type: string
          nullable: true
          example: '65432178'
        fax_number:
          type: string
          nullable: true
        notify_email:
          type: string
          nullable: true
          example: test@example.com
        zone:
          type: string
          nullable: true
        instructions:
          type: string
          nullable: true
        boxes:
          type: string
          nullable: true
        cubic_meters:
          type: number
          nullable: true
        cartons:
          type: integer
          nullable: true
        pieces:
          type: integer
          nullable: true
        envelopes:
          type: integer
          nullable: true
        pallets:
          type: integer
          nullable: true
        remarks:
          type: string
          nullable: true
        account_number:
          type: string
          nullable: true
        sales_person:
          type: string
          nullable: true
        pick_up_from:
          type: string
          nullable: true
        pick_up_time:
          type: string
          nullable: true
        pick_up_address:
          type: string
          nullable: true
        pick_up_address_1:
          type: string
          nullable: true
        pick_up_address_2:
          type: string
          nullable: true
        pick_up_address_3:
          type: string
          nullable: true
        pick_up_city:
          type: string
          nullable: true
        pick_up_state:
          type: string
          nullable: true
        pick_up_country:
          type: string
          nullable: true
        pick_up_postal_code:
          type: string
          nullable: true
        pick_up_zone:
          type: string
          nullable: true
        pick_up_lat:
          type: number
          nullable: true
        pick_up_lng:
          type: number
          nullable: true
        sender_phone_number:
          type: string
          nullable: true
        groups:
          type: array
          items:
            $ref: '#/components/schemas/ContactGroup'
        items:
          type: array
          items:
            $ref: '#/components/schemas/ContactItem'
    ContactItemInput:
      type: object
      description: >-
        An item to add, change, or remove. Without an `id`, it's added. Items
        with neither `sku` nor `description` are ignored.
      properties:
        id:
          type: string
          description: Send an existing item's `id` to change or remove that item.
        _destroy:
          type: boolean
          description: With `id`, set to `true` to remove the item.
        sku:
          type: string
          example: '12345678'
        description:
          type: string
          example: iPad
        quantity:
          type: number
          example: 2
        unit_price:
          type: number
        fixed_price:
          type: number
        minimum_quantity:
          type: number
        position:
          type: integer
          description: >-
            Order of the item in the contact's list. Defaults to its position in
            the array.
    ContactGroup:
      type: object
      properties:
        id:
          type: string
          example: 5e8b2f1a29e804cae4fe0a11
        name:
          type: string
          example: North
    ContactItem:
      type: object
      properties:
        id:
          type: string
          readOnly: true
          example: 6526409e29e804cae4fedd81
        sku:
          type: string
          nullable: true
          example: '12345678'
        description:
          type: string
          nullable: true
          example: iPad
        quantity:
          type: number
          nullable: true
          example: 2
        unit_price:
          type: number
          nullable: true
        fixed_price:
          type: number
          nullable: true
        minimum_quantity:
          type: number
          nullable: true
        position:
          type: integer
          description: Order of the item in the contact's list.
          example: 0
    Error:
      type: object
      properties:
        code:
          type: string
          example: not_found
        message:
          type: string
          example: Could not find job with this DO number
  responses:
    BadRequest:
      description: The request body isn't valid JSON.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            code: invalid_json_format
    Unauthorized:
      description: >-
        The API key is missing or invalid. A missing `X-API-KEY` returns `{
        "error": "Missing Authorization header" }`; an invalid key returns `{
        "code": "invalid_key", "message": "Invalid key" }`.
      content:
        application/json:
          schema:
            oneOf:
              - type: object
                title: Missing key
                required:
                  - error
                properties:
                  error:
                    type: string
                    example: Missing Authorization header
              - type: object
                title: Invalid key
                required:
                  - code
                properties:
                  code:
                    type: string
                    example: invalid_key
                  message:
                    type: string
                    example: Invalid key
          example:
            code: invalid_key
            message: Invalid key
    Forbidden:
      description: Your API key's user doesn't have permission for this action.
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: forbidden
          example:
            code: forbidden
    ServerError:
      description: >-
        Unexpected server error. Retry with exponential backoff, and contact
        Detrack support if it persists.
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-KEY
      description: Your Detrack API key, from **Integrations > API Key** in the dashboard.

````

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