Users

As the name suggests, users are a core part of Protocol. On this page, we'll dive into the different user endpoints you can use to manage users programmatically. We'll look at how to query, create, update, and delete users.

The contact model

The user model contains all the information about your users, such as their email, avatar, and phone number. It also contains a reference to the products, orders associated with the user.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the contact.

  • Name
    email
    Type
    string
    Description

    The email for the contact.

  • Name
    username
    Type
    string
    Description

    The username for the contact.

  • Name
    phone_number
    Type
    string
    Description

    The phone number for the contact.

  • Name
    avatar_url
    Type
    string
    Description

    The avatar image URL for the contact.

  • Name
    display_name
    Type
    string
    Description

    The contact display name in the contact list. By default, this is just the username.

  • Name
    biography
    Type
    string
    Description

    The contact's biography. Little discription filled by the user.

  • Name
    last_active_at
    Type
    timestamp
    Description

    Timestamp of when the contact was last active on the platform.

  • Name
    created_at
    Type
    timestamp
    Description

    Timestamp of when the contact was created.

  • Name
    balance
    Type
    number
    Description

    The balance of the user.

  • Name
    country_code
    Type
    string
    Description

    The country code of the user.

  • Name
    address
    Type
    string
    Description

    The address of the user.


GET/v1/users

List all users

This endpoint allows you to retrieve a paginated list of all your users. By default, a maximum of ten contacts are shown per page.

Optional attributes

  • Name
    limit
    Type
    integer
    Description

    Limit the number of contacts returned.

Request

GET
/v1/contacts
curl -G https://api.thefashionpeople.com/v1/users \
  -H "Authorization: Bearer {token}" \
  -d active=true \
  -d limit=10

Response

{
  "has_more": false,
  "data": [
    {
      "id": "WAz8eIbvDR60rouK",
      "username": "FrankMcCallister",
      "email": "test@example.com",
      "phone_number": "1-800-759-3000",
      "avatar_url": "https://cdn.thefashionpeople.com/avatars/frank.jpg",
      "display_name": null,
      "biography": "I love fashion, and I love to talk about it!",
      "last_active_at": 705103200,
      "created_at": 692233200,
      "balance": 1000,
      "country_code": "KZ",
      "address": "1234 Hollywood Blvd, Los Angeles, CA 90028"
    },
    {
      "id": "hSIhXBhNe8X1d8Et"
      // ...
    }
  ]
}

POST/v1/users

Create user

This endpoint allows you to create a new user in your users list.

Required attributes

  • Name
    email
    Type
    string
    Description

    The email for the contact.

  • Name
    password
    Type
    string
    Description

    The password for the contact.

  • Name
    country_code
    Type
    string
    Description

    The country code of the user.

Optional attributes

  • Name
    avatar_url
    Type
    string
    Description

    The avatar image URL for the contact.

  • Name
    display_name
    Type
    string
    Description

    The contact display name in the contact list. By default, this is just the username.

  • Name
    phone_number
    Type
    string
    Description

    The phone number for the contact.

  • Name
    biography
    Type
    string
    Description

    The contact's biography. Little discription filled by the user.

  • Name
    address
    Type
    string
    Description

    The address of the user.

Request

POST
/v1/users
curl https://api.thefashionpeople.com/v1/users \
  -H "Authorization: Bearer {token}" \
  -d email="test@example.com" \
  -d password="Lets1Make2Fashion3!@#" \
  -d phone_number="1-800-759-3000" \
  -d avatar_url="https://cdn.thefashionpeople.com/avatars/frank.jpg"

Response

{
  "id": "WAz8eIbvDR60rouK",
  "email": "test@example.com",
  "username": "FrankMcCallister",
  "phone_number": "1-800-759-3000",
  "avatar_url": "https://cdn.thefashionpeople.com/avatars/frank.jpg",
  "display_name": null,
  "last_active_at": null,
  "created_at": 692233200
}

GET/v1/users/:id

Retrieve a contact

This endpoint allows you to retrieve a user by providing their id.

Request

GET
/v1/users/WAz8eIbvDR60rouK
curl https://api.thefashionpeople.com/v1/users/WAz8eIbvDR60rouK \
  -H "Authorization: Bearer {token}"

Response

{
  "id": "WAz8eIbvDR60rouK",
  "email": "test@example.com",
  "username": "FrankMcCallister",
  "phone_number": "1-800-759-3000",
  "avatar_url": "https://cdn.thefashionpeople.com/avatars/frank.jpg",
  "display_name": null,
  "last_active_at": null,
  "created_at": 692233200
}
DELETE/v1/users/:id

Delete a contact

This endpoint allows you to delete user from your contact list in Protocol.

Request

DELETE
/v1/users/WAz8eIbvDR60rouK
curl -X DELETE https://api.thefashionpeople.com/v1/users/WAz8eIbvDR60rouK \
  -H "Authorization: Bearer {token}"