---
title: "Create a contact, attached to a supplier or to a wholesale account"
method: POST
path: "/api/v1/contacts"
tags: ["contacts"]
---

# Create a contact, attached to a supplier or to a wholesale account

`POST /api/v1/contacts`

## Request

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

Creates one contact and answers 201 with it. `name` and `preferred_contact_method` are required; `preferred_contact_method` is `EMAIL` or `PHONE`, and the field it names has to be in the same body (an email for EMAIL, a phone for PHONE), or the call is refused 400.

`supplier_id` attaches the contact to a supplier and `trading_partner_id` attaches it to a wholesale account. They are separate fields on purpose: the two resolve through different tables, and one person can legitimately belong to both at once. An id neither table has fails the call rather than creating a person attached to nothing. A contact who is the first on an account becomes that account's main contact; nobody is promoted afterwards, because who leads is a decision somebody makes rather than an accident of insert order.

`description` is capped at 1,024 characters, `department` and `role` at 255. An email another contact already has is refused 400 with "Contact already exists. The email must be unique."

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

## Headers

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

## Request body

- CreateContactRequest
  - `city` string, nullable
  - `country` string, nullable
  - `department` string, nullable
  - `description` string, nullable
  - `email` string, email
  - `name` string, required
  - `phone` string, nullable
  - `preferred_contact_method` string, required
  - `role` string, nullable
  - `supplier_id` string, nullable
  - `trading_partner_id` string, nullable

## Response `201`

The contact as created, with its supplier named.

- CreateContactResponse
  - `data` 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
  - `message` ContactsApiMessage
    - `desc` string
    - `service` string
    - `severity` 'SUCCESS' | 'INFO' | 'ERROR' | 'WARNING'

## Other responses

- `400`: A required field is missing, the preferred method names a field that is not there, or the email belongs to another contact.
- `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)
