Skip to main content
GET
/
api
/
v1
/
users
/
{id}
curl -X GET "http://localhost:3000/api/v1/users/user_123abc" \
  -H "Authorization: Bearer sk_your_secret_key_here"
{
  "id": "user_123abc",
  "first_name": "John",
  "last_name": "Doe",
  "email": "john.doe@example.com",
  "program_id": "prog_123abc",
  "profile_picture": "https://example.com/profiles/john-doe.jpg",
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-20T14:45:00Z",
  "metadata": {
    "student_id": "STU-2024-001",
    "major": "Computer Science",
    "year": "Junior"
  }
}
Retrieve detailed information about a specific student ambassador by their unique ID. Use this endpoint when you need complete details about a single user, such as their profile information, program enrollment, and activity statistics.

Overview

The Get User endpoint returns comprehensive information about a single student ambassador. This is useful for:
  • Displaying user profile pages
  • Showing detailed ambassador information
  • Fetching user data before making updates
  • Building user detail views in dashboards

Authentication

This endpoint requires authentication using a Bearer token in the Authorization header:
Authorization: Bearer sk_your_secret_key_here

Path Parameters

id
string
required
The unique identifier of the user (student ambassador) you want to retrieve. This ID is returned when you list users or create a new user.Example: user_123abc

Request Example

curl -X GET "http://localhost:3000/api/v1/users/user_123abc" \
  -H "Authorization: Bearer sk_your_secret_key_here"

Response

The API returns a detailed user object containing all available information about the student ambassador:
id
string
required
Unique identifier for the user.
first_name
string
required
First name of the student ambassador.
last_name
string
required
Last name of the student ambassador.
email
string
required
Email address of the student ambassador.
program_id
string
required
ID of the program this user belongs to.
profile_picture
string
URL to the user’s profile picture, if available.
created_at
string
required
ISO 8601 timestamp of when the user was created.
updated_at
string
ISO 8601 timestamp of when the user was last updated.
metadata
object
Additional metadata associated with the user. This can include custom fields you’ve added.

Response Example

{
  "id": "user_123abc",
  "first_name": "John",
  "last_name": "Doe",
  "email": "john.doe@example.com",
  "program_id": "prog_123abc",
  "profile_picture": "https://example.com/profiles/john-doe.jpg",
  "created_at": "2024-01-15T10:30:00Z",
  "updated_at": "2024-01-20T14:45:00Z",
  "metadata": {
    "student_id": "STU-2024-001",
    "major": "Computer Science",
    "year": "Junior"
  }
}

Error Responses

401
object
Unauthorized - Invalid or missing API key
{
  "error": "Unauthorized",
  "message": "Invalid or missing API key"
}
404
object
Not Found - The user with the specified ID does not exist
{
  "error": "Not Found",
  "message": "User not found"
}

Use Cases

Displaying User Profile

Fetch user details to display in a profile page:
async function getUserProfile(userId) {
  try {
    const response = await fetch(
      `http://localhost:3000/api/v1/users/${userId}`,
      {
        headers: {
          'Authorization': `Bearer ${API_KEY}`
        }
      }
    );
    
    if (response.status === 404) {
      throw new Error('User not found');
    }
    
    if (!response.ok) {
      throw new Error('Failed to fetch user');
    }
    
    return await response.json();
  } catch (error) {
    console.error('Error fetching user:', error);
    throw error;
  }
}

Validating User Existence

Before performing operations on a user, verify they exist:
async function userExists(userId) {
  const response = await fetch(
    `http://localhost:3000/api/v1/users/${userId}`,
    {
      headers: {
        'Authorization': `Bearer ${API_KEY}`
      }
    }
  );
  
  return response.status === 200;
}

Building User Detail Components

Use this endpoint to populate user detail views:
async function UserDetail({ userId }) {
  const [user, setUser] = useState(null);
  const [loading, setLoading] = useState(true);
  
  useEffect(() => {
    async function fetchUser() {
      try {
        const response = await fetch(
          `http://localhost:3000/api/v1/users/${userId}`,
          {
            headers: {
              'Authorization': `Bearer ${API_KEY}`
            }
          }
        );
        
        if (response.ok) {
          const userData = await response.json();
          setUser(userData);
        }
      } catch (error) {
        console.error('Error:', error);
      } finally {
        setLoading(false);
      }
    }
    
    fetchUser();
  }, [userId]);
  
  if (loading) return <div>Loading...</div>;
  if (!user) return <div>User not found</div>;
  
  return (
    <div>
      <h1>{user.first_name} {user.last_name}</h1>
      <p>{user.email}</p>
      {/* Render other user details */}
    </div>
  );
}

Best Practices

  1. Cache user data - User information doesn’t change frequently, so cache responses to reduce API calls
  2. Handle 404 errors - Always check if the user exists before displaying their information
  3. Validate user IDs - Ensure the ID format is correct before making the request
  4. Use error boundaries - Implement proper error handling in your UI components

Rate Limits

This endpoint is subject to rate limiting. Check the response headers for rate limit information.

Authorizations

Authorization
string
header
required

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

Path Parameters

id
string
required

User (student) ID

Response

User details

The response is of type object.