Users .: Create a Guest User

API Reference / v15

Create a Guest User

This endpoint creates a one-time guest user for order ahead checkout purposes. The client must store the returned access_token as there is no way to request a new one without creating a new guest account. Guests cannot be created with emails that already exist on non-guest users.

Request Endpoint

POST/v15/apps/users

No Header Authorization Required

Request Body

{
  "api_key": "23eef8c2895ce66eb4500bb5e324b200f5339e6fe6d8665f6de0205f43f3b563",
  "user": {
    "email": "ryanp@thelevelup.com",
    "first_name": "Ryan",
    "last_name": "Punxsutawney",
    "phone": "(555) 555-5555",
    "guest": true
  },
  "permission_keynames": [
    "manage_user_payment_methods",
    "create_orders"
  ]
}

Request Parameters

Param Required Description
api_key Yes Your API Key.
email Yes The new user’s email address.
first_name Yes The new user’s first name.
last_name Yes The new user’s last name.
phone No The new user’s phone number.
guest Yes Set this to true to create guest account.
permission_keynames Yes Array of permissions

cURL Example

curl https://sandbox.thelevelup.com/v15/apps/users \
  -H Accept:application/json \
  -H Content-Type:application/json \
  -d '{
    "api_key": "23eef8c2895ce66eb4500bb5e324b200f5339e6fe6d8665f6de0205f43f3b563",
    "user": {
      "email": "ryanp@thelevelup.com",
      "first_name": "Ryan",
      "last_name": "Punxsutawney",
      "phone": "(555) 555-5555",
      "guest": true
    },
    "permission_keynames": [
      "manage_user_payment_methods",
      "create_orders"
    ]
  }'

Example Response

HTTP/1.1 200 OK

{
  "user": {
    "born_at": null,
    "cause_id": null,
    "connected_to_facebook": false,
    "custom_attributes": {},
    "custom_gender": null,
    "debit_card_only": false,
    "email": "ryan.punxsutawney.1592234407@levelupguestaccount.com",
    "first_name": "Ryan",
    "gender": null,
    "global_credit_amount": 0,
    "guest_email": "ryanp@thelevelup.com",
    "id": 11316296,
    "last_name": "Punxsutawney",
    "merchants_visited_count": 0,
    "orders_count": 0,
    "phone": "(555) 555-5555",
    "phone_is_verified": false,
    "terms_accepted_at": null,
    "total_savings_amount": 0,
    "user_app_id": 12241033
  },
  "access_token": {
    "token": "1327578-k5q51..."
  }
}

Errors

HTTP/1.1 422 Unprocessable Entity To enable guest ordering for your app, email support@thelevelup.com.

[
  {
      "error": {
          "code": "no_guest_ordering",
          "message": "This app does not support guest ordering.",
          "object": "user",
          "property": "base"
      }
  }
]

HTTP/1.1 422 Unprocessable Entity

[
  {
    "error": {
      "message": "Permissions missing or keynames invalid",
      "object": "user",
      "property": "base"
    }
  }
]

HTTP/1.1 422 Unprocessable Entity - User already exists in the system

[
    {
        "error": {
            "code": "user_exists",
            "message": "This app is powered by LevelUp. You already have a LevelUp account that you created when registering for the following
            LevelUp-powered app: App Name. Please install LevelUp and log in with that account, then try again.",
            "object": "user",
            "property": "base"
        }
    }
]