# SENAR API Documentation

This document provides technical information for developers working with Senar's data. It includes instructions for:

* Authenticating access to the API
* Adding users and assigning collections
* Accessing user and activity data
* Registering webhooks for real-time data notifications

Each section includes endpoint examples and JSON responses to guide you. If you're new to Senar or integrating its data into your system, this guide will help you get started smoothly.

***

## 1. Authentication

**Method:** POST

You need to be authenticated to access Senar's data. Please contact support to obtain your login and password.

**Endpoint**

`https://studio.senar.io/api/auth/login`

**Request Body**

```json5
{
    "username": "xxx@xxx.com",
    "password": "*********"
}
```

**Response**

```json5
{
    "Token": "eedx..."
}
```

\
The resulting token is used in the rest of the requests to authenticate you. It must be included in the `Authorization` header using the Bearer scheme.&#x20;

**Example:**

```makefile
Authorization: Bearer <eedx...>
```

***

## 2. Add User and Assign Collection

**Method:** POST

Use this endpoint to add a new user and assign them to a specific collection.

**Endpoint**

`https://studio.senar.io/integration/data/user_assign`

**Request Body**

```json5
{
  "email": "new.user@example.com",
  "firstName": "New",
  "lastName": "User",
  "password": "Password8",
  "organization": "NewOrg Inc.",
  "collectionId": 42
}
```

**Response**

```json5
{
  "succeed": true,
  "email": "new.user@example.com",
  "collectionId": 42,
  "isNewUser": true
}
```

**Notes:**

* This endpoint requires authentication (see section 1).
* The `collectionId` must reference a valid collection owned by the authenticated user.
* &#x20;To find a collection’s ID , open it in Senar Studio and copy the number at the end of the URL. Example: `https://studio.senar.io/Collections/Edit/42` \
  → `42`&#x20;
* To assign multiple collections, repeat the request with a different `collectionId` each time.
* The `password` field must comply with Senar’s format requirements: at least 6 characters, containing letters and at least one number.
* User information can't be updated or deleted via the API — please use Senar Studio to make changes.

***

## 3. Get Users

**Method:** GET

Users register via a form available within the Senar application. This endpoint returns all users associated with the authenticated account.

**Endpoint**

`https://studio.senar.io/integration/data/users`

**Sample Response**

```json5
[{
    "id": "765fc7cf-312b-469d-8508-0e943a6447c7",
    "firstName": "Jon",
    "lastName": "Doe",
    "email": "jon.doe@my.mail",
    "language": "en",
    "accountName": "ACME",
    "countryName": "USA",
    "creationDate": "2022-09-07T06:25:23.9014976",
    "profile": "Instructor"
}]
```

***

## 4. Get Activity Data

**Method:** GET

An activity represents the data collected when a user completes a scenario.

**Endpoint**

`https://studio.senar.io/integration/data/activities`

**Sample Response**

```json5
[{
    "id": 80119,
    "collectionId": 41,
    "userId": "b68bfbd8-8f26-427b-a3c9-2d4cec36648b",
    "traineeId": "b5e3bbbc-0c22-417a-8087-6554afe26400",
    "firstName": "Natalia",
    "lastName": "Brown",
    "company": "Daria",
    "trainingDate": "2021-03-09T17:37:11.186836",
    "scenarioId": "S01",
    "scenarioName": "Scenario 1",
    "totalPoints": 2900,
    "totalSec": 622,
    "totalTries": 1,
    "simulatorId": 18,
    "tilts": 0,
    "totalMaxPoints": 3400,
    "abandons": 1,
    "collectionTitle": "Rigging",
    "simulatorTitle": "Lifting Hardware and Sling Inspection",
    "userFirstName": "Jon",
    "userLastName": "Doe",
    "userEmail": "jon.doe@my.mail",
    "userCostCenter": "East",
    "userAccountName": "ACME",
    "traineeEmail": "guest-b45@senar.io",
    "traineeProfile": "Guest"
}]
```

***

## 5. Webhook Registration

**Method:** POST

Use webhooks to receive real-time notifications when new users or activities are recorded. The response returns an ID you can use later to unsubscribe from the webhook if needed.

**Endpoint**

`https://studio.senar.io/integration/data/webhook_register`

**Request Body**

```json5
{
  "hookUrl": "",
  "method": "activity",  // or "user"
  "provider": "zapier"
}
```

**Response**

```json5
{
    "id": "<webhook_id>"
}
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://support.senar.io/senar-api/senar-api-documentation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
