Skip to main content
GET
/
v2
/
users
/
{userId}
Get a single User
curl --request GET \
  --url https://api.affinity.co/v2/users/{userId} \
  --header 'Authorization: Bearer <token>'
import requests

url = "https://api.affinity.co/v2/users/{userId}"

headers = {"Authorization": "Bearer <token>"}

response = requests.get(url, headers=headers)

print(response.text)
const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};

fetch('https://api.affinity.co/v2/users/{userId}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.affinity.co/v2/users/{userId}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"net/http"
"io"
)

func main() {

url := "https://api.affinity.co/v2/users/{userId}"

req, _ := http.NewRequest("GET", url, nil)

req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.get("https://api.affinity.co/v2/users/{userId}")
.header("Authorization", "Bearer <token>")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.affinity.co/v2/users/{userId}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'

response = http.request(request)
puts response.read_body
{
  "id": 1,
  "firstName": "Jane",
  "lastName": "Doe",
  "primaryEmailAddress": "jane.doe@acme.co",
  "photoUrl": "https://assets.affinity.co/img/avatars/jane-doe.png",
  "status": "active",
  "emailAddresses": [
    "jane.doe@acme.co",
    "janedoe@gmail.com"
  ],
  "role": "standard"
}
{
"errors": [
{
"code": "bad-request",
"message": "<string>"
}
]
}
{
"errors": [
{
"code": "authorization",
"message": "<string>"
}
]
}
{
"errors": [
{
"code": "not-found",
"message": "<string>"
}
]
}
{
"errors": [
{
"code": "authentication",
"message": "<string>"
}
]
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

userId
integer<int32>
required

User ID

Required range: 1 <= x <= 2147483647

Response

OK

An internal user in your organization, including their name, primary email address, all email addresses, photo URL, account status, and account role.

id
integer<int32>
required

The user's unique identifier

Required range: 1 <= x <= 2147483647
Example:

1

firstName
string
required

The user's first name

Example:

"Jane"

lastName
string | null
required

The user's last name

Example:

"Doe"

primaryEmailAddress
string<email> | null
required

The user's primary email address

Example:

"jane.doe@acme.co"

photoUrl
string<uri> | null
required

URL of the user's profile photo

Example:

"https://assets.affinity.co/img/avatars/jane-doe.png"

status
enum<string>
required

The user's account status.

  • active: the user can sign in and use Affinity.
  • invited: the user has been invited to the product but has not yet accepted the invitation and thus cannot have taken any actions.
  • deactivated: the user was once active but has been deactivated and can no longer use the product.
Available options:
active,
invited,
deactivated
Example:

"active"

emailAddresses
string<email>[]

All of the user's email addresses. Only returned when the authenticated user has the "Manage Users" permission.

Maximum array length: 100
Example:
["jane.doe@acme.co", "janedoe@gmail.com"]
role
string

The user's account role. Only returned when the authenticated user has the "Manage Users" permission.

Example:

"standard"