# Create a customer

> POST /api/public/v1/customers, scope directory.write. Techvia TMS public API v1 reference.

Source: https://techvia.software/docs/tms/reference/customers/create-a-customer/

`POST /api/public/v1/customers`

**Scope:** `directory.write`. **MCP tool:** `create_customer`. Rules and edge cases: [Customers guide](/docs/tms/guides/directory/).

## Request body

Content type `application/json`. Limits and rules for each field are in the [Customers guide](/docs/tms/guides/directory/).

| Field | Type | Required | Notes |
|---|---|---|---|
| `name` | string | no |  |
| `mcType` | string | no |  |
| `mcNumber` | string | no |  |
| `street` | string | no |  |
| `city` | string | no |  |
| `state` | string | no |  |
| `zip` | string | no |  |
| `country` | string | no |  |
| `contactName` | string | no |  |
| `phone` | string | no |  |
| `email` | string | no |  |
| `confirmNew` | boolean | no | Default `false` |

## Responses

| Status | Meaning | Body |
|---|---|---|
| `201` | Created | `PublicCustomer` |
| `409` | Conflict | `ProblemDetails` |
| `422` | Unprocessable Entity | `ProblemDetails` |

### `201` body

| Field | Type | Notes |
|---|---|---|
| `id` | string (uuid) |  |
| `name` | string |  |
| `mcType` | string |  |
| `mcNumber` | string |  |
| `city` | string |  |
| `state` | string |  |
| `status` | enum CustomerStatus | One of `Active`, `Inactive` |
| `contactName` | string |  |
| `phone` | string |  |
| `email` | string |  |
| `rowVersion` | integer |  |

Errors are RFC 7807 problem details; see [Errors](/docs/tms/concepts/errors/).

**Example request**

**curl**

```bash
curl -X POST "https://tms-api.techvia.software/api/public/v1/customers" \
  -H "Authorization: Bearer $TMS_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "name": "FreshMart Stores",
    "mcType": "MC",
    "mcNumber": "MC-773120",
    "street": "9 Market St",
    "city": "Phoenix",
    "state": "AZ",
    "zip": "85001",
    "contactName": "Lena Ortiz",
    "phone": "602-555-0142",
    "email": "ap@freshmart.example"
  }'
```

**JavaScript**

```js
const res = await fetch(`https://tms-api.techvia.software/api/public/v1/customers`, {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.TMS_KEY}`,
    'Content-Type': 'application/json',
    'Idempotency-Key': crypto.randomUUID(),
  },
  body: JSON.stringify({
    "name": "FreshMart Stores",
    "mcType": "MC",
    "mcNumber": "MC-773120",
    "street": "9 Market St",
    "city": "Phoenix",
    "state": "AZ",
    "zip": "85001",
    "contactName": "Lena Ortiz",
    "phone": "602-555-0142",
    "email": "ap@freshmart.example"
  }),
});
if (!res.ok) throw new Error(await res.text());
console.log(await res.json());
```

**Python**

```python

res = requests.request(
    "POST",
    f"https://tms-api.techvia.software/api/public/v1/customers",
    headers={"Authorization": f"Bearer {os.environ['TMS_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={
      "name": "FreshMart Stores",
      "mcType": "MC",
      "mcNumber": "MC-773120",
      "street": "9 Market St",
      "city": "Phoenix",
      "state": "AZ",
      "zip": "85001",
      "contactName": "Lena Ortiz",
      "phone": "602-555-0142",
      "email": "ap@freshmart.example"
    },
)
res.raise_for_status()
print(res.json())
```

**Example response** `201`

```json
{
  "id": "01a20943-7a10-7c11-8a2e-000000000030",
  "name": "FreshMart Stores",
  "mcType": "MC",
  "mcNumber": "MC-773120",
  "city": "Phoenix",
  "state": "AZ",
  "status": "Active",
  "contactName": "Lena Ortiz",
  "phone": "602-555-0142",
  "email": "ap@freshmart.example",
  "rowVersion": 311
}
```

<p class="ep-caption">Illustrative values.</p>
