> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vantio.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Get User

> Retrieve detailed information about a specific student ambassador

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:

```bash theme={null}
Authorization: Bearer sk_your_secret_key_here
```

## Path Parameters

<ParamField body="id" type="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`
</ParamField>

## Request Example

<RequestExample>
  ```bash theme={null}
  curl -X GET "https://vantio.app/api/v1/users/user_123abc" \
    -H "Authorization: Bearer sk_your_secret_key_here"
  ```
</RequestExample>

## Response

The API returns a detailed user object containing all available information about the student ambassador:

<ResponseField name="id" type="string" required>
  Unique identifier for the user.
</ResponseField>

<ResponseField name="first_name" type="string" required>
  First name of the student ambassador.
</ResponseField>

<ResponseField name="last_name" type="string" required>
  Last name of the student ambassador.
</ResponseField>

<ResponseField name="email" type="string" required>
  Email address of the student ambassador.
</ResponseField>

<ResponseField name="program_id" type="string" required>
  ID of the program this user belongs to.
</ResponseField>

<ResponseField name="profile_picture" type="string">
  URL to the user's profile picture, if available.
</ResponseField>

<ResponseField name="created_at" type="string" required>
  ISO 8601 timestamp of when the user was created.
</ResponseField>

<ResponseField name="updated_at" type="string">
  ISO 8601 timestamp of when the user was last updated.
</ResponseField>

<ResponseField name="metadata" type="object">
  Additional metadata associated with the user. This can include custom fields you've added.
</ResponseField>

## Response Example

<ResponseExample>
  ```json theme={null}
  {
    "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"
    }
  }
  ```
</ResponseExample>

## Error Responses

<ResponseField name="401" type="object">
  **Unauthorized** - Invalid or missing API key

  ```json theme={null}
  {
    "error": "Unauthorized",
    "message": "Invalid or missing API key"
  }
  ```
</ResponseField>

<ResponseField name="404" type="object">
  **Not Found** - The user with the specified ID does not exist

  ```json theme={null}
  {
    "error": "Not Found",
    "message": "User not found"
  }
  ```
</ResponseField>

## Use Cases

### Displaying User Profile

Fetch user details to display in a profile page:

```javascript theme={null}
async function getUserProfile(userId) {
  try {
    const response = await fetch(
      `https://vantio.app/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:

```javascript theme={null}
async function userExists(userId) {
  const response = await fetch(
    `https://vantio.app/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:

```javascript theme={null}
async function UserDetail({ userId }) {
  const [user, setUser] = useState(null);
  const [loading, setLoading] = useState(true);
  
  useEffect(() => {
    async function fetchUser() {
      try {
        const response = await fetch(
          `https://vantio.app/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.


## OpenAPI

````yaml GET /api/v1/users/{id}
openapi: 3.0.0
info:
  title: Vantio API
  version: 1.0.0
  description: >-
    Public v1 API. Authenticate using your secret key in the Authorization
    header: "Bearer sk_...".
servers:
  - url: http://localhost:3000
security:
  - bearerAuth: []
tags:
  - name: Users
    description: Student directory within your programs
  - name: Referrals
    description: Signups and conversions
  - name: Posters
    description: Ambassador posters and placements
  - name: Impressions
    description: QR scans and related activity
  - name: Earnings
    description: Earnings from referrals
paths:
  /api/v1/users/{id}:
    get:
      tags:
        - Users
      summary: Get a specific user by ID
      description: Retrieve detailed information about a specific student ambassador
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
          description: User (student) ID
      responses:
        '200':
          description: User details
          content:
            application/json:
              schema:
                type: object
        '401':
          description: Unauthorized - Invalid or missing API key
        '404':
          description: User not found
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key

````