# Users

# Paginate Users

GET
/users

# Example Request

curl --location --request GET 'https://yourwebsite.com/api/users' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}'

# Example Response

{
    "data": [
        {
            "id": 123,
            "first_name": "John",
            "last_name": "Doe",
            "username": "johndoe",
            "email": "[email protected]",
            "phone": "+381641234567",
            "avatar": "http://yourwebsite.com/users/john-doe-avatar.jpg",
            "address": "Some random street, 123, Serbia",
            "country_id": 688,
            "role_id": 1,
            "status": "Active",
            "birthday": "1989-01-03",
            "last_login": "2017-04-27 16:47:59",
            "two_factor_country_code": 381,
            "two_factor_phone": "6412345678",
            "two_factor_options": {
                "option1": 4,
                "option2": "option value"
            },
            "created_at": "2017-04-20 16:47:59",
            "updated_at": "2017-04-27 10:47:59"
        },
        // ...
    ],
    // ...
}

# Available includes

If provided, the available includes will be part of the response for each ticket object.

role

User's role details.

country

User's country details

# Sortable Fields

id (default), first_name, last_name, email, updated_at, created_at.

# Partial filters

A search filter that can be used as a partial search for the following fields: username, first_name, last_name and email.

# Exact filters

status

# Create User

POST
/users

# Parameters

Parameter Type Required Description
email String Yes User's email address.
username String No User's username.
password String Yes User's password.
password_confirmation String Yes Password confirmation.
role_id Number Yes User's role id. Check roles for more info.
first_name String No User's first name.
last_name String No User's last name.
birthday Date No User's birth date.
phone String No User's phone number.
address String No User's full address.
country_id Number No The ID of the users country. Check countries endpoint for more info.

# Example Request

curl --location --request POST 'https://yourwebsite.com/api/users' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
  "email": "[email protected]",
  "password": "123123",
  "password_confirmation": "123123",
  "role_id": 1,
  "username": "johndoe",
  "first_name": "John",
  "last_name": "Doe",
  "phone": "+381641234567",
  "address": "Some random street, 123, Serbia",
  "country_id": 688,
  "birthday": "1989-01-03"
}'

# Example Response

{
    "data": {
        "id": 123,
        "first_name": "John",
        "last_name": "Doe",
        "username": "johndoe",
        "email": "[email protected]",
        "phone": "+381641234567",
        "avatar": "http://yourwebsite.com/users/john-doe-avatar.jpg",
        "address": "Some random street, 123, Serbia",
        "country_id": 688,
        "role_id": 1,
        "status": "Active",
        "birthday": "1989-01-03",
        "last_login": "2017-04-27 16:47:59",
        "two_factor_country_code": 381,
        "two_factor_phone": "6412345678",
        "two_factor_options": {
          "option1": 4,
          "option2": "option value"
        },
        "created_at": "2017-04-20 16:47:59",
        "updated_at": "2017-04-27 10:47:59"
    }
}

# Get User

GET
/users/{id}

# Parameters

Parameter Type Required Description
id Number Yes User's ID.

# Example Request

curl --location --request GET 'https://yourwebsite.com/api/users/123' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}'

# Example Response

{
    "data": {
        "id": 123,
        "first_name": "John",
        "last_name": "Doe",
        "username": "johndoe",
        "email": "[email protected]",
        "phone": "+381641234567",
        "avatar": "http://yourwebsite.com/users/john-doe-avatar.jpg",
        "address": "Some random street, 123, Serbia",
        "country_id": 688,
        "role_id": 1,
        "status": "Active",
        "birthday": "1989-01-03",
        "last_login": "2017-04-27 16:47:59",
        "two_factor_country_code": 381,
        "two_factor_phone": "6412345678",
        "two_factor_options": {
          "option1": 4,
          "option2": "option value"
        },
        "created_at": "2017-04-20 16:47:59",
        "updated_at": "2017-04-27 10:47:59"
    }
}

# Available includes

If provided, the available includes will be part of the response for each ticket object.

role

User's role details.

country

User's country details

# Update User

PATCH
/users/{id}

# Parameters

Parameter Type Required Description
email String No User's email address.
username String No User's username.
password String No User's password.
password_confirmation String No Password confirmation.
role_id Number No User's role id. Check roles for more info.
first_name String No User's first name.
last_name String No User's last name.
birthday Date No User's birth date.
phone String No User's phone number.
address String No User's full address.
country_id Number No The ID of the users country. Check countries endpoint for more info.

# Example Request

curl --location --request GET 'https://yourwebsite.com/api/users/123' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
  "username": "johndoe",
  "first_name": "John",
  "last_name": "Doe"
}'

# Example Response

{
    "data": {
        "id": 123,
        "first_name": "John",
        "last_name": "Doe",
        "username": "johndoe",
        "email": "[email protected]",
        "phone": "+381641234567",
        "avatar": "http://yourwebsite.com/users/john-doe-avatar.jpg",
        "address": "Some random street, 123, Serbia",
        "country_id": 688,
        "role_id": 1,
        "status": "Active",
        "birthday": "1989-01-03",
        "last_login": "2017-04-27 16:47:59",
        "two_factor_country_code": 381,
        "two_factor_phone": "6412345678",
        "two_factor_options": {
          "option1": 4,
          "option2": "option value"
        },
        "created_at": "2017-04-20 16:47:59",
        "updated_at": "2017-04-27 10:47:59"
    }
}

# Delete User

DELETE
/users/{id}

# Example Request

curl --location --request DELETE 'https://yourwebsite.com/api/users/123' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}'

# Example Response

Status: 200 OK

{
  "success": true
}

# Upload Avatar

POST
/users/{id}/avatar

# Example Request

curl --location --request POST 'https://yourwebsite.com/api/users/123/avatar' \
--header 'Accept: application/json' \
--header 'Content-Type: multipart/form-data' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}' \
--form 'file=image.jpg'

# Example Response

{
    "data": {
        "id": 123,
        "first_name": "John",
        "last_name": "Doe",
        "username": "johndoe",
        "email": "[email protected]",
        "phone": "+381641234567",
        "avatar": "http://yourwebsite.com/users/john-doe-avatar.jpg",
        "address": "Some random street, 123, Serbia",
        "country_id": 688,
        "role_id": 1,
        "status": "Active",
        "birthday": "1989-01-03",
        "last_login": "2017-04-27 16:47:59",
        "two_factor_country_code": 381,
        "two_factor_phone": "6412345678",
        "two_factor_options": {
          "option1": 4,
          "option2": "option value"
        },
        "created_at": "2017-04-20 16:47:59",
        "updated_at": "2017-04-27 10:47:59"
    }
}

# Update Avatar from External Source

PUT
/users/{id}/avatar/external
Parameter Type Required Description
url String Yes URL to an external avatar image.

# Example Request

curl --location --request PUT 'https://yourwebsite.com/api/users/123/avatar/external' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
  "url": "https://s.gravatar.com/avatar/20208b38fbb6018920da7d038fbc58dc?s=80"
}'

# Example Response

{
    "data": {
        "id": 123,
        "first_name": "John",
        "last_name": "Doe",
        "username": "johndoe",
        "email": "[email protected]",
        "phone": "+381641234567",
        "avatar": "http://yourwebsite.com/users/john-doe-avatar.jpg",
        "address": "Some random street, 123, Serbia",
        "country_id": 688,
        "role_id": 1,
        "status": "Active",
        "birthday": "1989-01-03",
        "last_login": "2017-04-27 16:47:59",
        "two_factor_country_code": 381,
        "two_factor_phone": "6412345678",
        "two_factor_options": {
          "option1": 4,
          "option2": "option value"
        },
        "created_at": "2017-04-20 16:47:59",
        "updated_at": "2017-04-27 10:47:59"
    }
}

# Enable 2FA

PUT
/users/{id}/2fa

# Parameters

Parameter Type Required Description
country_code Number Yes ISO 3166-1 country code.
phone_number Number Yes Phone number without country code part.

# Example Request

curl --location --request PUT 'https://yourwebsite.com/api/users/123/2fa' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
  "country_code": 381,
  "phone_number": 6412345678
}'

# Example Response

{
    "data": {
        "id": 123,
        "first_name": "John",
        "last_name": "Doe",
        "username": "johndoe",
        "email": "[email protected]",
        "phone": "+381641234567",
        "avatar": "http://yourwebsite.com/users/john-doe-avatar.jpg",
        "address": "Some random street, 123, Serbia",
        "country_id": 688,
        "role_id": 1,
        "status": "Active",
        "birthday": "1989-01-03",
        "last_login": "2017-04-27 16:47:59",
        "two_factor_country_code": 381,
        "two_factor_phone": "6412345678",
        "two_factor_options": {
          "option1": 4,
          "option2": "option value"
        },
        "created_at": "2017-04-20 16:47:59",
        "updated_at": "2017-04-27 10:47:59"
    }
}

# Verify 2FA Phone Number

POST
/users/{id}/2fa/verify

# Parameters

Parameter Type Required Description
token String Yes Token received via SMS.

# Example Request

curl --location --request POST 'https://yourwebsite.com/api/users/123/2fa/verify' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}' \
--data-raw '{
  "token": "213456789"
}'

# Example Response

{
    "data": {
        "id": 123,
        "first_name": "John",
        "last_name": "Doe",
        "username": "johndoe",
        "email": "[email protected]",
        "phone": "+381641234567",
        "avatar": "http://yourwebsite.com/users/john-doe-avatar.jpg",
        "address": "Some random street, 123, Serbia",
        "country_id": 688,
        "role_id": 1,
        "status": "Active",
        "birthday": "1989-01-03",
        "last_login": "2017-04-27 16:47:59",
        "two_factor_country_code": 381,
        "two_factor_phone": "6412345678",
        "two_factor_options": {
          "option1": 4,
          "option2": "option value"
        },
        "created_at": "2017-04-20 16:47:59",
        "updated_at": "2017-04-27 10:47:59"
    }
}

# Disable 2FA

DELETE
/users/{id}/2fa

# Example Request

curl --location --request DELETE 'https://yourwebsite.com/api/users/123/2fa' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}'

# Example Response

{
    "data": {
        "id": 123,
        "first_name": "John",
        "last_name": "Doe",
        "username": "johndoe",
        "email": "[email protected]",
        "phone": "+381641234567",
        "avatar": "http://yourwebsite.com/users/john-doe-avatar.jpg",
        "address": "Some random street, 123, Serbia",
        "country_id": 688,
        "role_id": 1,
        "status": "Active",
        "birthday": "1989-01-03",
        "last_login": "2017-04-27 16:47:59",
        "two_factor_country_code": 381,
        "two_factor_phone": "6412345678",
        "two_factor_options": {
          "option1": 4,
          "option2": "option value"
        },
        "created_at": "2017-04-20 16:47:59",
        "updated_at": "2017-04-27 10:47:59"
    }
}

# Get Sessions

GET
/users/{id}/sessions

# Example Request

curl --location --request GET 'https://yourwebsite.com/api/users/123/sessions' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {api_key}' \
--header 'Authorization: Bearer {api_key}'

# Example Response

{
    "data": [
        {
            "id": "uFfF2KPoq7XZAOPLhen5ayOArawyzGitjoFIdogV",
            "user_id": 1,
            "ip_address": "123.45.67.890",
            "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36",
            "browser": "Chrome",
            "platform": "OS X",
            "device": "Macintosh",
            "last_activity": "2017-08-18 14:30:09"
        },
        // ...
    ]
}