File size: 2,891 Bytes
e6410cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Users API

This document outlines the API endpoints for managing users in PySpur.
Users and sessions are required for deploying agents and chatbots that maintain message history.

## Create User

**Description**: Creates a new user. If a user with the given external ID already exists, returns the existing user.

**URL**: `/user/`

**Method**: POST

**Request Payload**:
```python
class UserCreate:
    external_id: str  # External identifier for the user
    user_metadata: Optional[Dict[str, Any]] = None  # Additional metadata about the user
```

**Response Schema**:
```python
class UserResponse:
    id: str  # User ID (prefixed with 'U')
    external_id: str  # External identifier for the user
    user_metadata: Optional[Dict[str, Any]]  # Additional metadata about the user
    created_at: datetime  # When the user was created
    updated_at: datetime  # When the user was last updated
```

## List Users

**Description**: Lists users with pagination.

**URL**: `/user/`

**Method**: GET

**Query Parameters**:
```python
skip: int = 0  # Number of users to skip (min: 0)
limit: int = 10  # Number of users to return (min: 1, max: 100)
```

**Response Schema**:
```python
class UserListResponse:
    users: List[UserResponse]  # List of users
    total: int  # Total number of users
```

## Get User

**Description**: Gets a specific user by ID.

**URL**: `/user/{user_id}/`

**Method**: GET

**Parameters**:
```python
user_id: str  # User ID (prefixed with 'U')
```

**Response Schema**:
```python
class UserResponse:
    id: str  # User ID (prefixed with 'U')
    external_id: str  # External identifier for the user
    user_metadata: Optional[Dict[str, Any]]  # Additional metadata about the user
    created_at: datetime  # When the user was created
    updated_at: datetime  # When the user was last updated
```

## Update User

**Description**: Updates a user.

**URL**: `/user/{user_id}/`

**Method**: PATCH

**Parameters**:
```python
user_id: str  # User ID (prefixed with 'U')
```

**Request Payload**:
```python
class UserUpdate:
    external_id: Optional[str] = None  # External identifier for the user
    user_metadata: Optional[Dict[str, Any]] = None  # Additional metadata about the user
```

**Response Schema**:
```python
class UserResponse:
    id: str  # User ID (prefixed with 'U')
    external_id: str  # External identifier for the user
    user_metadata: Optional[Dict[str, Any]]  # Additional metadata about the user
    created_at: datetime  # When the user was created
    updated_at: datetime  # When the user was last updated
```

## Delete User

**Description**: Deletes a user.

**URL**: `/user/{user_id}/`

**Method**: DELETE

**Parameters**:
```python
user_id: str  # User ID (prefixed with 'U')
```

**Response**: 204 No Content