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

# Get User Assignments

> Get a list of courses assigned to the user

Retrieve a list of all courses assigned to a specific user.

## Request Headers

**X-API-KEY** `string` *required*

API Key. Go to your Konstantly site > Settings > API and copy the value from there.

## URL Parameters

**userId** `string` *required*

User API ID

## Response

**assignments** `array` *required*

Array of course assignments

**Assignment properties**

**assignedAt** `integer` *required*

Timestamp when course was assigned

**startedAt** `integer` *required*

Timestamp when user started the course

**deadlineAt** `integer` *required*

Timestamp when assignment expires

**finishedAt** `integer` *required*

Timestamp when user finished the course

**progressValue** `integer` *required*

Current progress (0-100)

**resultValue** `integer` *required*

Course result (0-100)

**isCourseStarted** `boolean` *required*

Whether user has started the course

**isCourseFinished** `boolean` *required*

Whether user has finished the course

**isExpired** `boolean` *required*

Whether assignment has expired

**course** `object` *required*

Course details

**Course properties**

**id** `integer` *required*

Course ID

**name** `string` *required*

Course name

**annotation** `string` *required*

Course annotation

**isDraft** `boolean` *required*

Draft status

**createdAt** `integer` *required*

Creation timestamp

**updatedAt** `integer` *required*

Last update timestamp

**publishedAt** `integer` *required*

Publication timestamp

**image** `object`

Course cover image

### Error Responses

**404** `object`

Not Found error response

**Error object properties**

**status** `integer` *required*

HTTP status code (404)

**message** `string` *required*

Error message

```bash cURL theme={null}
curl --request GET \
--url 'https://YOURSITE.konstant.ly/openapi/v1/users/1234567890/assignments' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
```

```python Python theme={null}
import requests

def get_user_assignments(api_key: str, user_id: str) -> dict:
url = f"https://YOURSITE.konstant.ly/openapi/v1/users/{user_id}/assignments"
headers = {"X-API-KEY": api_key}

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

if response.status_code == 404:
raise ValueError(f"User {user_id} not found")

response.raise_for_status()
return response.json()

# Example usage
try:
assignments = get_user_assignments("1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv", "1234567890")
for assignment in assignments['assignments']:
course = assignment['course']
print(f"Course: {course['name']}")
print(f"Progress: {assignment['progressValue']}%")
print(f"Status: {'Completed' if assignment['isCourseFinished'] else 'In Progress'}")
print("---")
except Exception as e:
print(f"Error: {str(e)}")
```

```javascript Node.js theme={null}
const axios = require('axios');

async function getUserAssignments(apiKey, userId) {
try {
const response = await axios.get(
`https://YOURSITE.konstant.ly/openapi/v1/users/${userId}/assignments`,
{
headers: {
'X-API-KEY': apiKey
}
}
);
return response.data;
} catch (error) {
if (error.response?.status === 404) {
throw new Error(`User ${userId} not found`);
}
throw error;
}
}

// Example usage
getUserAssignments('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv', '1234567890')
.then(data => {
data.assignments.forEach(assignment => {
    console.log(`Course: ${assignment.course.name}`);
    console.log(`Progress: ${assignment.progressValue}%`);
    console.log(`Status: ${assignment.isCourseFinished ? 'Completed' : 'In Progress'}`);
    console.log('---');
});
})
.catch(error => console.error('Error:', error.message));
```

```json Response theme={null}
{
    "assignments": [
{
    "assignedAt": 1443183322,
    "startedAt": 1443188932,
    "deadlineAt": 1444188932,
    "finishedAt": 1443188946,
    "progressValue": 100,
    "resultValue": 50,
    "isCourseStarted": true,
    "isCourseFinished": true,
    "isExpired": false,
    "course": {
    "id": 123,
    "name": "Introduction to Sales",
    "annotation": "Learn the basics of sales",
    "isDraft": false,
    "createdAt": 1507807711,
    "updatedAt": 1507808372,
    "publishedAt": 1508225229,
    "image": null
}
}
    ]
}
```

```json 404 Error theme={null}
{
    "status": 404,
    "message": "Not found"
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.