You can add a buyer by calling the POST /buyers API. The call accepts an optional external_identifier (for example the user’s email, username, or a database ID) and an optional display_name which will be shown in the admin panel.

curl -i -X POST "https://api.example.gr4vy.app/buyers" \
    -H "Authorization: Bearer [JWT_TOKEN]" \
    -H "Content-Type: application/json" \
    -d '{
          "display_name": "John L.",
          "external_identifier": "412231123"
        }'

A buyer can be created without any external_identifier and display_name. In that case, the buyer only serves as a way to link stored payment methods to a user ID. In this situation, you will need to keep track of the buyer’s ID in your database to link it back to a user record.

The API returns a new buyer resource.

POST /buyers
{
  "type": "buyer",
  "id": "fe26475d-ec3e-4884-9553-f7356683f7f9",
  "external_identifier": "412231123",
  "display_name": "John L.",
  "created_at": "2013-07-16T19:23:00.000Z",
  "updated_at": "2013-07-16T19:23:00.000Z"
}