# CreateTradingPartner

Creates a new trading partner.

`POST /trading-partners`

**API:** Avalara E-Invoicing API
**Tag:** Trading Partners
**API Version:** 1.6
**Base URL:** https://api.sbx.avalara.com/einvoicing
**Authentication:** Bearer token

Source: https://developer.avalara.com/products/e-invoicing/api/v1.6/methods/Trading%20Partners/CreateTradingPartner/

## Description

This endpoint creates a new trading partner with the provided details. The request body must include the necessary information as defined in the `TradingPartner` schema.

## Parameters

| Name | Type | In | Required | Description |
|---|---|---|---|---|
| `avalara-version` | string | header | Yes | Header that specifies the API version to use (for example "1.6"). |
| `X-Avalara-Client` | string | header | No | Optional header for a client identifier string used for diagnostics (for example "Fingerprint"). |
| `X-Correlation-ID` | string | header | No | Optional correlation identifier provided by the caller to trace the call (for example "f3f0d19a-01a1-4748-8a58-f000d0424f43"). |

## Request Body

**Content-Type:** `application/json`
**Schema:** `TradingPartner`

Represents a participant in the Avalara directory.

| Property | Type | Required | Description |
|---|---|---|---|
| `id` | string | No | Avalara unique ID of the participant in the directory. |
| `name` | string | **Yes** | Name of the participant (typically, the name of the business entity). |
| `network` | string | No | The network where the participant is present. When creating or updating a trading partner, the value provided for the attribute 'network' will be ignored. |
| `registrationDate` | string | No | Registration date of the participant if available. |
| `identifiers` | Identifier[] | **Yes** | A list of identifiers associated with the trading partner. Each identifier should consistently include the fields name, and value to maintain clarity and ensure consistent structure across entries. When creating or updating a trading partner, the attribute 'name' must be agreed upon with Avalara to ensure consistency. Failing to adhere to the agreed values will result in a validation error. Further, when creating or updating a trading partner, the value provided for the attribute 'displayName' will be ignored and instead retrieved from the standard set of display names maintained. |
| `addresses` | Address[] | **Yes** |  |
| `supportedDocumentTypes` | SupportedDocumentTypes[] | **Yes** | A list of document types supported by the trading partner for exchange. Each document type identifier value must match the standard list maintained by Avalara, which includes Peppol and other public network document type identifier schemes and values, as well as any approved partner-specific identifiers. The 'value' field must exactly match an entry from the provided document identifier list. Any attempt to submit unsupported document types will result in a validation error. Further, when creating or updating a trading partner, the value provided for the attributes 'name' and 'supportedByAvalara' will be ignored. |
| `consents` | Consents | No |  |
| `extensions` | Extension[] | No | Optional array used to carry additional metadata or configuration values that may be required by specific networks. When creating or updating a trading partner, the keys provided in the 'extensions' attribute must be selected from a predefined list of supported extensions. Using any unsupported keys will result in a validation error. |

## Responses

| Status | Description | Schema |
|---|---|---|
| 201 | The trading partner has been successfully created. |  |
| 400 | Bad request | `ErrorResponse` |
| 401 | Unauthorized. | `ErrorResponse` |
| 403 | Forbidden. | `ErrorResponse` |
| 409 | Conflict | `ErrorResponse` |
| 500 | Internal server error. | `ErrorResponse` |

## Example Request

```bash
curl -X POST "https://api.sbx.avalara.com/einvoicing/trading-partners" \
  -H "Authorization: Basic <credentials>" \
  -H "Accept: application/json" \
  -d '{
  "id": "",
  "name": "",
  "network": "",
  "registrationDate": "",
  "identifiers": [
    {
      "name": "",
      "displayName": "",
      "value": "",
      "extensions": [
        {
          "key": "",
          "values": [
            {}
          ]
        }
      ]
    }
  ],
  "addresses": [
    {
      "line1": "",
      "line2": "",
      "city": "",
      "state": "",
      "country": "",
      "postalCode": ""
    }
  ],
  "supportedDocumentTypes": [
    {
      "name": "",
      "value": "",
      "supportedByTradingPartner": "",
      "supportedByAvalara": "",
      "extensions": [
        {
          "key": "",
          "values": [
            {}
          ]
        }
      ]
    }
  ],
  "consents": {
    "listInAvalaraDirectory": ""
  },
  "extensions": [
    {
      "key": "",
      "values": [
        {}
      ]
    }
  ]
}'
```