---
title: "Create suppliers and their contacts in one call"
method: POST
path: "/api/v1/inventory/suppliers"
tags: ["suppliers"]
---

# Create suppliers and their contacts in one call

`POST /api/v1/inventory/suppliers`

## Request

- Base URL: `https://api.app.tightly.io`
- URL: `https://api.app.tightly.io/api/v1/inventory/suppliers`
- Auth: HTTP bearer

Creates suppliers and answers 201 with each one as get_supplier_details serves it. The body is `{"suppliers": [...]}`; every entry needs a `name`, and may carry the address, `currency`, `min_order_value`, `lead_time`, `payment_terms_days`, `domains`, a `contacts` list and a `primary_contact`.

A supplier's id is derived from its name, so this call is idempotent on the name and never overwrites. Posting a name that already exists answers the supplier on file, unchanged, with none of the fields in the body applied, and 201 either way. update_supplier is the door for changing a supplier that exists. Two entries with the same name in one body are collapsed to the first.

`contacts` are created with the supplier and deduplicated on (email, name). A contact with no `preferred_contact_method` takes email when an email is given and phone otherwise, and in that same case a contact with an email and no name takes the local part of the address, state `preferred_contact_method` yourself and the name stays null. `primary_contact` names an existing contact by `id` and does not create one.

`domains` is what routes a supplier's mail: a domain like `acme.example` or a whole address like `orders@acme.example`. Anything that is neither is refused 400, because a bad entry matches nothing and nothing reports it.

Scope: `suppliers:write`, which includes `suppliers:read`.

## Headers

- `Tightly-Version` string
- `Idempotency-Key` string

## Request body

- CreateSuppliersRequest
  - `suppliers` SupplierPayload[]
    - `address1` string, nullable
    - `address2` string, nullable
    - `city` string, nullable
    - `contacts` SupplierContactPayload[], nullable
      - `city` string, nullable
      - `country` string, nullable
      - `department` string, nullable
      - `description` string, nullable
      - `email` string, email, nullable
      - `id` string, nullable
      - `name` string, nullable
      - `phone` string, nullable
      - `preferred_contact_method` string, nullable
      - `role` string, nullable
      - `supplier_id` string, nullable
      - `supplier_name` string, nullable
    - `country` string, nullable
    - `currency` string, nullable
    - `domains` string[], nullable
    - `kind` 'factory' | 'vendor' | 'distributor' | 'null', nullable
    - `lead_time` integer, nullable
    - `min_order_value` integer, nullable
    - `name` string, required
    - `payment_terms_days` integer, nullable
    - `postal_code` string, nullable
    - `primary_contact` union
      - SupplierContactPayload
        - `city` string, nullable
        - `country` string, nullable
        - `department` string, nullable
        - `description` string, nullable
        - `email` string, email, nullable
        - `id` string, nullable
        - `name` string, nullable
        - `phone` string, nullable
        - `preferred_contact_method` string, nullable
        - `role` string, nullable
        - `supplier_id` string, nullable
        - `supplier_name` string, nullable
      - object, nullable
    - `province` string, nullable

## Response `201`

The suppliers as they now stand, the ones created, and unchanged for any name that already existed.

- CreateSuppliersResponse
  - `data` union
    - CreateSuppliersPayload
      - `suppliers` SupplierDetailsWithContacts[], required
        - `address1` string, nullable
        - `address2` string, nullable
        - `average_lead_time` union
          - InventoryCardItem
            - `info` string, nullable
            - `key` string, required
            - `unit` string, required
            - `value` unknown
          - object, nullable
        - `brands` SupplierBrandRef[]
          - `brand_id` string, required
          - `name` string, required
          - `owned` boolean
        - `city` string, nullable
        - `contacts` ContactPayload[]
          - `city` string, nullable
          - `country` string, nullable
          - `department` string, nullable
          - `description` string, nullable
          - `email` string, nullable
          - `id` string, required
          - `is_primary_contact` boolean, nullable
          - `name` string, nullable
          - `phone` string, nullable
          - `preferred_contact_method` string, nullable
          - `role` string, nullable
          - `supplier_id` string, nullable
          - `supplier_name` string, nullable
        - `container_type_id` integer, nullable
        - `country` string, nullable
        - `currency` string, nullable
        - `domains` string[], nullable
        - `edi` union
          - SupplierEdi
            - `account_number` string, nullable
            - `trading_partner_id` string, nullable
            - `vendor_number` string, nullable
          - object, nullable
        - `id` string, required
        - `in_full` number, nullable
        - `integrations` object, nullable
        - `is_archived` boolean, nullable
        - `kind` string, nullable
        - `lanes` SupplierLane[], nullable
          - `basis` string, nullable
          - `container_name` string, nullable
          - `container_type_id` integer, nullable
          - `freight_per_container_cents` integer, nullable
          - `internal_cbm` number, nullable
          - `lead_time` integer, nullable
          - `lead_time_source` string, nullable
          - `location_id` string, required
          - `location_name` string, nullable
          - `pallet_positions` integer, nullable
          - `payload_kg` integer, nullable
          - `resolved_container_type_id` integer, nullable
          - `road_limit_kg` integer, nullable
          - `usable_pct` number, nullable
        - `lead_time` integer, nullable
        - `lead_time_source` string, nullable
        - `location_lead_times` SupplierLocationLeadTime[], nullable
          - `lead_time` integer, nullable
          - `location_id` string, required
          - `location_name` string, nullable
          - `source` string, nullable
        - `min_order_value` integer, nullable
        - `name` string, required
        - `on_time` number, nullable
        - `otif_score` number, nullable
        - `payment_terms_days` integer, nullable
        - `postal_code` string, nullable
        - `primary_contact` union
          - ContactPayload
            - `city` string, nullable
            - `country` string, nullable
            - `department` string, nullable
            - `description` string, nullable
            - `email` string, nullable
            - `id` string, required
            - `is_primary_contact` boolean, nullable
            - `name` string, nullable
            - `phone` string, nullable
            - `preferred_contact_method` string, nullable
            - `role` string, nullable
            - `supplier_id` string, nullable
            - `supplier_name` string, nullable
          - object, nullable
        - `province` string, nullable
    - object, nullable
  - `message` ApiMessage
    - `desc` string
    - `service` string
    - `severity` 'SUCCESS' | 'INFO' | 'ERROR' | 'WARNING'

## Other responses

- `400`: An entry has no `name`, or a `domains` entry is neither a domain nor an address.
- `401`: No usable key: malformed, unknown, revoked, expired or stopped. One refusal covers all five, telling a caller which is which maps the surface for them. A request with no Authorization header at all is refused 400 before any key is looked for.
- `403`: The key may not reach this operation. `scope_missing` when the key does not hold Suppliers; `ip_not_allowed` when the caller's address is outside the key's allowlist. There is no `organization_mismatch` on this resource: no supplier or contact route names an organisation in its path, so there is nothing for a key to disagree with.
- `429`: The key has spent its allowance for this minute. 600 reads and 120 writes a minute, counted per key, refused calls included. `Retry-After` says how long to wait.
- `503`: The database is briefly out of reach, which is what a failover or a full connection pool looks like from outside. Wait the seconds `Retry-After` names and send the request again. A read is safe to repeat. A write is not, because the connection was lost in the middle of it, so read the object back before sending it a second time. Branch on the status rather than on `code`, which is `POSTGRES_UNAVAILABLE` from one of the two seams that raise this and `SERVICE_UNAVAILABLE` from the other.

---

[API](https://skmtc.dev/tightly/apis/tightly-api.md) · [All operations](https://skmtc.dev/tightly/apis/tightly-api/llms.txt) · [OpenAPI document](https://skmtc.dev/tightly/apis/tightly-api/revisions/199f7eb35afb?raw)
