Customers API

Register the people you sell to, then address a sale to one of them. The checkout arrives filled in, only that document can pay it, and a returning payer is not asked who they are at all.

What a customer record is

A customer record is a binding before it is a contact. Addressing a sale to one fixes which CPF or CNPJ may pay it — whoever opens the link — and the rest of what the record holds is there to fill the checkout form with.

Records have two live states. A draft is a pré-cadastro: data you typed, which you can correct. A confirmed record is a payer who has actually paid you — it describes them rather than your guess at them, so it is read-only, and because Glin has verified who they are, a sale addressed to one skips the identity step entirely.

Creating a record does not create a Glin account for the customer, does not start a compliance check and does not record any acceptance of terms on their behalf. Those belong to the payer, and happen when they pay.

Create or resolve a customer

POST/merchant-api/customers

Send what you know about the customer; get back the id that addresses a sale to them. The call is keyed on the document and never changes a record that already exists, so it is safe to repeat — no idempotency key needed. The same request works for a new buyer and for one who paid you last month: a new document creates a draft and answers 201, a known one answers 200 with the record you already have.

Request Body

Name Type Required Description
namestringThe customer's full name, or the company's. Up to 200 characters.
taxIdstringCPF or CNPJ, with or without punctuation. This is the document the sale is bound to: a payer holding any other one cannot pay it. Rejected if the checksum does not validate.
taxIdTypestringNATURAL_PERSON for a CPF, LEGAL_PERSON for a CNPJ. Must agree with the document you sent.
emailstring—Prefills the checkout and is where the payment confirmation goes.
phonestring—The payer's phone, from any country, in E.164: a plus sign, the country code, then the number.
addressobject—Prefills the checkout address form, which is otherwise the longest part of it for the payer.

Address Object

Name Type Required Description
zipCodestring—CEP, with or without the hyphen.
streetstring—Street name, without the number.
numberstring—Street number.
complementstring—Apartment, suite, floor.
neighborhoodstring—Bairro.
citystring—City name.
statestring—Two-letter state code, upper case (e.g. "SP").

Example Request

cURL
curl --request POST \
  --url https://pay.staging.glin.com.br/merchant-api/customers \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Ana Souza",
    "taxId": "123.456.789-09",
    "taxIdType": "NATURAL_PERSON",
    "email": "ana@example.com",
    "phone": "+5511987654321",
    "address": {
      "zipCode": "01310-100",
      "street": "Avenida Paulista",
      "number": "1578",
      "neighborhood": "Bela Vista",
      "city": "São Paulo",
      "state": "SP"
    }
  }'

Response — a new customer (201)

json
{
  "id": 4821,
  "status": "draft",
  "name": "Ana Souza",
  "taxId": "12345678909",
  "taxIdType": "NATURAL_PERSON",
  "email": "ana@example.com",
  "phone": "+5511987654321",
  "address": {
    "zipCode": "01310100",
    "street": "Avenida Paulista",
    "number": "1578",
    "neighborhood": "Bela Vista",
    "city": "São Paulo",
    "state": "SP"
  },
  "createdAt": "2026-10-26T14:02:11Z",
  "updatedAt": "2026-10-26T14:02:11Z"
}

Response — a returning payer (200)

The same request, for a document that has already paid you. Note the confirmed status, the masked CPF and the absent address.

json
{
  "id": 5120,
  "status": "confirmed",
  "name": "Ana Souza",
  "taxId": "***.***.***-09",
  "taxIdType": "NATURAL_PERSON",
  "email": "ana@example.com",
  "phone": "+5511987654321",
  "createdAt": "2026-08-14T09:30:00Z",
  "updatedAt": "2026-10-02T18:11:40Z"
}

This is how you look a customer up. There is no list or search endpoint: post the document and you get the record, whether or not it existed.

Read a customer

GET/merchant-api/customers/{id}

Returns the same object. Customer ids are scoped to your account, so another merchant's id reads as missing rather than forbidden.

Correct a draft

PUT/merchant-api/customers/{id}

Takes the same body as POST and replaces every field, so send the whole record — a field you leave out is cleared, including the address.

Only a draft can be corrected. Once a payer has confirmed the record by paying, it is theirs and the request is refused with merchant-customer.read-only. Use POST for corrections and you will get the unchanged record back, not an updated one.

Address a sale to a customer

Pass the id as customerId when you create the sale. It is optional: omit it and the payer states who they are, which stays the ordinary case.

cURL
curl --request POST \
  --url https://pay.staging.glin.com.br/merchant-api/remittances \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "clientReferenceId": "INV-7781",
    "type": "target_amount_fixed",
    "amount": 450.00,
    "currency": "BRL",
    "customerId": 4821
  }'

What changes for the payer who opens that sale's checkoutUrl or shortUrl:

  • Name, document, e-mail and phone arrive filled in.
  • The address arrives filled in too, if the record is a draft carrying one.
  • Only that document can pay the sale. Someone else opening the link — even with the link forwarded to them — cannot complete it.
  • If the record is confirmed and complete, the identity step does not appear at all. The payer goes straight to paying.

The assignment is fixed when the sale is created and cannot be moved afterwards. If you addressed a sale to the wrong person, cancel it and create another.

The same rule applies when you charge the sale yourself through /remittances/{id}/prepare and /remittances/{id}/pay: the payer those requests name must hold the document the sale is addressed to, or the call is refused with remittance.customer-not-assigned. The check is on the document, not on the id — so registering the payer through the checkout flow and passing the id that comes back works, even though it is a different record from the draft you addressed the sale to.

A draft cannot be charged directly. It is your description of someone, not a payer Glin has met — there is no verified identity to charge under, so /prepare and /pay refuse it with merchant-customer.not-registered. Either send the payer to the hosted checkout, where they identify themselves and the document stays pinned, or register them first with POST /checkout-api/customer/register and charge under the id that returns.

Getting the id back after a payment

When a payer pays, Glin confirms the bond between them and your account. That confirmed record — not the draft you created — is the one to address their next sale to, and GET /merchant-api/remittances/{id}/customer now reports its id.

json
{
  "id": 5120,
  "name": "Ana Souza",
  "email": "ana@example.com",
  "countryCode": "BR",
  "taxId": "12345678909",
  "address": {
    "address1": "Avenida Paulista, 1578",
    "neighborhood": "Bela Vista",
    "city": "São Paulo",
    "province": "SP",
    "zip": "01310100",
    "country": "BR"
  }
}

You do not have to store it. Posting the same document to POST /customers resolves to the confirmed record, which is why one code path covers both first-time and returning buyers.

The draft you created is retired once the sale is paid, and reading it will show archived. That is expected: the confirmed record replaces it.

What comes back, and what does not

Response Fields

Name Type Required Description
idnumberThe customer id, scoped to your account. Send it as customerId when creating a sale, or as data.customerId to the checkout SDK. It is never the payer's identifier on Glin.
statusstring"draft" — a pré-cadastro you created and may still correct. "confirmed" — a payer who has paid you, so the record describes them rather than your guess at them, and is read-only.
namestringThe name on the record.
taxIdstringWhole while the record is a draft. Once confirmed, a CPF shows only its last two digits; a CNPJ stays whole. See "What comes back" below.
taxIdTypestringNATURAL_PERSON or LEGAL_PERSON.
emailstring—The e-mail on the record.
phonestring—The phone on the record, normalised to digits with a leading "+".
addressobject—Present only on a draft, and only if you sent one.
createdAtstringISO 8601, UTC.
updatedAtstringISO 8601, UTC.

Documents. A draft's document is the value you sent, so it comes back whole. Once a payer has confirmed the record, the document is theirs rather than yours: a CPF then comes back showing only its last two digits — enough to recognise a returning payer — while a CNPJ, which identifies a company rather than a person, stays whole. This is the same rule the Glin dashboard applies. You can always resolve a record by posting the full document you already hold.

Addresses. An address is only reported while the record is a draft. When a payer confirms the record, the address they actually used becomes the record of where they are and this copy is dropped — so an address you send prefills the first sale, not every later one. To prefill an address on later sales, pass data.address to the checkout SDK, which fills the form per checkout without storing anything.

Errors

Name Type Required Description
400 invalid-request—A field failed validation. The violations array names each field and what was wrong with it.
400 merchant-customer.tax-id-invalid—The document is not a valid CPF or CNPJ for the taxIdType you sent.
400 merchant-customer.read-only—PUT on a record a payer has confirmed. Only drafts can be corrected.
400 merchant-customer.archived—The record was retired — a different payer paid the sale it was addressed to. Create a new one.
400 merchant-customer.not-registered—You passed a draft to /prepare or /pay. A draft has no verified payer behind it; send them to the hosted checkout, or register them first.
400 remittance.customer-not-assigned—The payer named does not hold the document the sale is addressed to. Compared by document, so a different record for the same person is fine.
404 not-found—No such customer on your account. Customer ids are scoped per account, so another merchant's id reads as missing rather than forbidden.