It is possible to bind a vaulted card to a buyer when it is being created. There are a few ways to do so.

Associate by buyer_id

The easiest way to associate a buyer with a card is to pass along a buyer_id when creating a card.

This will find a buyer with that id and associate the card with it. If a buyer with this id could not be found it’s ignored.

curl -i -X POST "https://api.example.gr4vy.app/payment-methods" \
    -H "Authorization: Bearer [JWT_TOKEN]" \
    -H "Content-Type: application/json" \
    -d '{
        "method": "card",
        "number": "4111111111111111",
        "expiration_date": "11 / 22",
        "security_code": "123",
        "buyer_id": "fe26475d-ec3e-4884-9553-f7356683f7f9"
      }'

Associate by buyer_external_identifier

Alternatively, a card can be associated with a buyer by its external_identifier. If a buyer with that external_identifier could not be found it’s ignored.

curl -i -X POST "https://api.example.gr4vy.app/payment-methods" \
    -H "Authorization: Bearer [JWT_TOKEN]" \
    -H "Content-Type: application/json" \
    -d '{
        "method": "card",
        "number": "4111111111111111",
        "expiration_date": "11 / 22",
        "security_code": "123",
        "buyer_external_identifier": "412231123"
      }'