Users .: Create

API Reference / v15

Create a User

This endpoint creates a user and returns an access token with the requested permissions.

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",
    "password": "secure_password_only",
    "custom_attributes": {
      "foo": "bar",
      "baz": "qux"
    }
  },
  "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.
password No The new user’s password. If password is not provided, future logins will only be possible if the password is set by updating the user.
permission_keynames Yes Array of permissions
custom_attributes No Arbitrary key-value data to associate with this user. Scoped by the API Key associated with the request’s access token. For more information about custom user attributes, see section “Custom user attributes”.

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",
      "password": "secure_password_only",
      "custom_attributes": {
        "foo": "bar",
        "baz": "qux"
      }
    },
    "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": {
      "foo": "bar",
      "baz": "qux"
    },
    "custom_gender": null,
    "debit_card_only": false,
    "email": "ryanp@thelevelup.com",
    "first_name": "Ryan",
    "gender": null,
    "global_credit_amount": 0,
    "id": 11316295,
    "last_name": "Punxsutawney",
    "merchants_visited_count": 0,
    "orders_count": 0,
    "phone": "(555) 555-5555",
    "terms_accepted_at": null,
    "total_savings_amount": 0,
    "user_app_id": 12241032
  },
  "access_token": {
    "token": "1327576-VSRwY9..."
  }
}

Errors

HTTP/1.1 422 Unprocessable Entity

[
  {
    "error": {
      "message": "Email is already associated with another app powered by LevelUp. If this is your account, you can go back to the login screen and log in using that email address and password.",
      "object": "user",
      "property": "email"
    }
  }
]

HTTP/1.1 422 Unprocessable Entity

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