• Example searches: “transaction”, “CreateOrder”, “/v2/locations”, “inventory”, “delete customer”

You are viewing an old version of the API
Create loyalty account

POST /v2/loyalty/accounts

Creates a loyalty account.

To create a loyalty account, you must provide the program_id and a mapping with the phone_number of the buyer.

Name Description
loyalty_account
LoyaltyAccount

Required

The loyalty account to create.

idempotency_key
string

Required

A unique string that identifies this CreateLoyaltyAccount request. Keys can be any valid string, but must be unique for every request.

Min Length 1 Max Length 128

Response Fields

Name Description
errors
Error [ ]

Any errors that occurred during the request.

loyalty_account
LoyaltyAccount

The newly created loyalty account.

Examples

You are viewing an old version of the API
POST /v2/loyalty/accounts
cURL
  • cURL
  • Ruby
  • Python
  • C#
  • Java
  • PHP
  • Node.js
curl https://connect.squareup.com/v2/loyalty/accounts \
  -X POST \
  -H 'Square-Version: 2021-05-13' \
  -H 'Authorization: Bearer ACCESS_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "loyalty_account": {
      "mapping": {
        "phone_number": "+14155551234"
      },
      "program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd"
    },
    "idempotency_key": "ec78c477-b1c3-4899-a209-a4e71337c996"
  }'
Response JSON
{
  "loyalty_account": {
    "id": "79b807d2-d786-46a9-933b-918028d7a8c5",
    "mapping": {
      "id": "66aaab3f-da99-49ed-8b19-b87f851c844f",
      "phone_number": "+14155551234",
      "created_at": "2020-05-08T21:44:32Z"
    },
    "program_id": "d619f755-2d17-41f3-990d-c04ecedd64dd",
    "balance": 0,
    "lifetime_points": 0,
    "created_at": "2020-05-08T21:44:32Z",
    "updated_at": "2020-05-08T21:44:32Z"
  }
}

Error Descriptions

400 Bad request INVALID_PHONE_NUMBER

The provided phone number is invalid.

>
400 Bad request
{
  "errors": [
    {
      "code": "INVALID_PHONE_NUMBER",
      "category": "INVALID_REQUEST_ERROR"
    }
  ]
}

Share Feedback

Thanks for visiting the Square API documentation. What's on your mind?