85 lines
1.7 KiB
Markdown
85 lines
1.7 KiB
Markdown
# Get User by ID
|
|
|
|
**GET /api/v1/users/{id}**
|
|
|
|
Retrieve user information by user ID within a tenant context.
|
|
|
|
**Authentication**: Required (JWT Bearer token)
|
|
|
|
**Tenant Context**: Required
|
|
|
|
**Headers**:
|
|
- `Authorization: JWT {access_token}`
|
|
- `X-Tenant-ID: {tenant_id}` (required in development mode)
|
|
|
|
**URL Parameters**:
|
|
|
|
| Parameter | Type | Required | Description |
|
|
|-----------|------|----------|-------------|
|
|
| id | UUID | Yes | User ID |
|
|
|
|
**Example Request**:
|
|
|
|
```bash
|
|
curl -X GET http://localhost:8000/api/v1/users/950e8400-e29b-41d4-a716-446655440000 \
|
|
-H "Authorization: JWT eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
|
|
-H "X-Tenant-ID: 850e8400-e29b-41d4-a716-446655440000"
|
|
```
|
|
|
|
**Example Response** (200 OK):
|
|
|
|
```json
|
|
{
|
|
"id": "950e8400-e29b-41d4-a716-446655440000",
|
|
"email": "jane@techstart.com",
|
|
"name": "Jane Smith",
|
|
"created_at": "2024-10-24T00:00:00Z",
|
|
"updated_at": "2024-10-24T00:00:00Z"
|
|
}
|
|
```
|
|
|
|
**Error Responses**:
|
|
|
|
This endpoint returns errors in **RFC 9457 (Problem Details for HTTP APIs)** format.
|
|
|
|
**Content-Type**: `application/problem+json`
|
|
|
|
**400 Bad Request** - Missing tenant context:
|
|
```json
|
|
{
|
|
"type": "about:blank",
|
|
"title": "Bad Request",
|
|
"status": 400,
|
|
"detail": "Tenant context required"
|
|
}
|
|
```
|
|
|
|
**401 Unauthorized**:
|
|
```json
|
|
{
|
|
"type": "about:blank",
|
|
"title": "Unauthorized",
|
|
"status": 401,
|
|
"detail": "Authentication required"
|
|
}
|
|
```
|
|
|
|
**404 Not Found**:
|
|
```json
|
|
{
|
|
"type": "about:blank",
|
|
"title": "Not Found",
|
|
"status": 404,
|
|
"detail": "User not found in this tenant"
|
|
}
|
|
```
|
|
|
|
**500 Internal Server Error**:
|
|
```json
|
|
{
|
|
"type": "about:blank",
|
|
"title": "Internal Server Error",
|
|
"status": 500,
|
|
"detail": "Failed to retrieve user"
|
|
}
|
|
```
|