> For the complete documentation index, see [llms.txt](https://docs.barte.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.barte.com/guias/pedidos-e-cobrancas/criando-um-comprador.md).

# Criando um Comprador

Na Barte, todo pedido (**order**) precisa estar associado a um **comprador**.\
Por isso, antes de criar uma order, é necessário registrar o comprador e obter o seu **`uuid`** ou buscar por um comprador já cadastrado para associá-lo ao pedido.

O **comprador** representa a pessoa física ou jurídica que realizará a transação.\
Ele armazena informações como:

* Nome e e-mail
* Documento (CPF/CNPJ ou documento internacional)
* Dados de contato
* Endereço

### Criar um comprador (Buyer)

O comprador representa a pessoa que realizará o pagamento.

#### Endpoint

```
POST /v2/buyers
https://api.barte.com/v2/buyers
```

#### Headers

```
X-Token-Api: YOUR_API_KEY
Content-Type: application/json
Accept: */*
```

#### Body

```json
{
  "document": {
    "documentNumber": "48637879012",
    "documentType": "cpf",
    "documentNation": "BR"
  },
  "name": "John Doe",
  "email": "johndoe@barte.com",
  "countryCode": "+55",
  "phone": "34999991111",
  "alternativeEmail": "johndoealt@barte.com",
  "address": {
    "street": "Rua Orleans",
    "number": "100",
    "complement": "Bloco A",
    "district": "Jardim Europa",
    "city": "Uberlândia",
    "state": "Minas Gerais",
    "country": "BR",
    "zipCode": "38414552"
  }
}
```

{% hint style="info" %}
**Comprador com documento internacional:** informe em `documentNation` o país emissor (ISO 3166-1 alfa-2) e em `documentType` o tipo do documento daquele país. Ex.: SSN dos Estados Unidos:

```json
"document": {
  "documentNumber": "536904399",
  "documentType": "ssn",
  "documentNation": "US"
}
```

Veja todas as combinações aceitas em [Documentos Aceitos](https://docs.barte.com/api-reference/compradores/documentos-aceitos). Passaporte não é aceito.
{% endhint %}

#### Response

```json
{
  "uuid": "1ee849a4-6bb3-47f0-b32a-293a8f0e811c",
  "document": "48637879012",
  "name": "John Doe",
  "countryCode": "+55",
  "phone": "34999991111",
  "email": "johndoe@barte.com",
  "alternativeEmail": "johndoe@barte.com"
}
```

> Guarde o campo **uuid**, ele será utilizado na criação do pedido.

Veja a referencia API do endpoint de criação de buyers clicando no link abaixo para entender sobre todos os campos, retornos de sucesso e erro e demais informações:

{% content-ref url="/spaces/hY03QzfTvLWOjOsYfPiz/pages/AWqGHk0JpyBAFok3KhB9" %}
[Criar Comprador](https://docs.barte.com/api-reference/compradores/criar-comprador.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.barte.com/guias/pedidos-e-cobrancas/criando-um-comprador.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
