# API

This feature allows you to download data and reports using the Crewmojo API. You can automate this process so that you can get a consistent stream of data and statistics for your system. For example, to populate a B.I. platform.

**Endpoints:**

<table><thead><tr><th width="141">Environment</th><th>URL</th></tr></thead><tbody><tr><td>Test</td><td><code>https://api.test.crewmojo.com/v1/integrations/download/*</code></td></tr><tr><td>Production</td><td><code>https://api.crewmojo.com/v1/integrations/download/*</code></td></tr></tbody></table>

**Request Type:**

<mark style="color:blue;">**POST**</mark>

**Content  Type:**

The reports are returned in either:

* csv format which is the default. In this case the first row being the column headings.
* json format. Set contentType to be json in the request body. See below.

**Security:**

The API will only accept encrypted connections over TLS (https).

Retrieve a short-lived Access Token (see [here](https://docs.crewmojo.com/integrations/crewmojo-api)).  You need to add this token to the 'Authorization' header of your HTTP POST:

* `Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cC...7rZ43t`

**Request Path:**

<table><thead><tr><th width="370">Value</th><th>Description</th></tr></thead><tbody><tr><td><pre><code><strong>/v1/integrations/download/rrrrrrrr
</strong></code></pre></td><td>rrrrrrr is the report identifier. Please speak to us about reports that you can access for your solution.</td></tr></tbody></table>

**Request Body:**

<table><thead><tr><th width="178">Value</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td>startDate</td><td>numeric, yyyymmdd format (optional)</td><td>start and end dates need to be present together</td></tr><tr><td>endDate</td><td>numeric, yyyymmdd format (optional)</td><td>start and end dates need to be present together</td></tr><tr><td>contentType</td><td>string</td><td>The data returned is csv by default. If you prefer json to be returned, then set contentType to json in the <strong>request body</strong>.</td></tr><tr><td>jobId</td><td>bool, true or false (optional)</td><td>Setting this value to true will force the report server to delay 30 seconds and return a jobId. This is useful for testing long running report process - see <a href="#long-running-reports">below</a>.</td></tr></tbody></table>

Each data report is identified by a string which is appended to the above endpoint paths.&#x20;

For example, to get a summary of 1:1's completed over a date range, the request would be something like this:

```
curl -X POST 'https://api.crewmojo.com/v1/integrations/download/oneonone.summary' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer access.token.here' \
-d '{"startDate":20240101,"endDate":20241231, "contentType": "json"}'
```

**Response:**

<table><thead><tr><th width="171">Code</th><th>Description / Example</th></tr></thead><tbody><tr><td>200</td><td><p><em>Success, report data returned immediately</em></p><p>Content-Type: text/csv</p><pre><code>Employee,Employee Code,Email,Manager,Manager Code,Active,Created Date,Invitation,Last Access,Employment Start,Employment End,Last 1-on-1 (12 months),Last Team Meeting (12 months),Active Teams,Active Hitchhiker's Guide Teams,Active Strategy and Planning Teams,Active Stars Only Teams,Active Division  Teams,Active Division  Teams,Current Position,Position History,Leave History,Gender,Home Address,State,Nickname,Relevant links,Mentor,Sparkle Factor,D.O.B,Security training
Adelina Amador,emp3,adelina.amador@test.crewmojo.com,James Fly,RTYUIOP,No,20200115,0,0,0,0,0,0,,,,,,,,,,,,,,,,,,
Adrian Willard,emp22,adrian.willard@test.crewmojo.com,James Fly,RTYUIOP,No,20210629,20221031,0,20130812,0,0,0,- Nat. Team Co-ordinators,,- Construction,,,,Mechanical Plant Engineer,- Mechanical Plant Engineer (29 Jun 2021),,,,,,,,,,
Alan Fink,emp6,alan.fink@test.crewmojo.com,James Fly,RTYUIOP,No,20200115,0,0,0,0,0,0,,,,,,,Mechanical Plant Engineer,,,,,,,,,,,
</code></pre></td></tr><tr><td>200</td><td><p><em>Log running report (after 30 seconds). See</em> <a href="#long-running-reports"><em>below</em></a> <em>for further action.</em></p><p>Content-Type: application/json</p><pre><code>{
  "success": "true",
  "jobId": "cab1790ced8c44e47f7c5d087f19bb66"
}
</code></pre></td></tr><tr><td>400</td><td><p><em>Invalid data error</em></p><p>Content-Type: application/json</p><pre><code>{
  "success": "false",
  "httpErrorCode": 400,
  "errorMessage": "Invalid data received"
}
</code></pre></td></tr><tr><td>401</td><td><p></p><p><em>Unauthorized error</em></p><p>Content-Type: application/json</p><pre><code>{
  "success": "false",
  "httpErrorCode": 401,
  "errorMessage": "Unauthorized"
}
</code></pre></td></tr><tr><td>500</td><td><p><em>Internal Server Error</em></p><p>Content-Type: application/json</p><pre><code>{
  "success": "false",
  "httpErrorCode": 500,
  "errorMessage": "Error generating report"
}
</code></pre></td></tr></tbody></table>

{% hint style="info" %}
Please speak to us about the reports available and their corresponding identifiers.&#x20;
{% endhint %}

#### Long running reports

If a report takes longer than 30 seconds to generate, then it is considered a long running report. In this case, the report API will return a jobId which you will then use to poll for a result.&#x20;

{% hint style="info" %}
Each jobId will expire 10 minutes after the original request. Make sure you retrieve the report data before this time.
{% endhint %}

**Endpoints:**

<table><thead><tr><th width="141">Environment</th><th>URL</th></tr></thead><tbody><tr><td>Test</td><td><code>https://api.test.crewmojo.com/v1/integrations/download/*</code></td></tr><tr><td>Production</td><td><code>https://api.crewmojo.com/v1/integrations/download/*</code></td></tr></tbody></table>

**Request Type:**

<mark style="color:blue;">**GET**</mark>

**Content  Type:**

<mark style="color:blue;">**text/csv**</mark>

The reports are returned in csv format with the first row being the column headings.

**Security:**

Same security as above

**Request Path:**

<table><thead><tr><th width="475">Value</th><th>Description</th></tr></thead><tbody><tr><td><pre><code><strong>/v1/integrations/download/rrrrrrrr?jobId=jjjjjjj
</strong></code></pre></td><td>rrrrrrr is the report identifier. Please speak to us about reports that you can access for your solution.<br><br>jjjjjjj is the jobId</td></tr></tbody></table>

**Response:**

The possible responses are the same as the initial request responses.

If the total time exceeds 5 minutes, then abandon the report request and try again. If this continues, please contact us.&#x20;


---

# 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://docs.crewmojo.com/download/api.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.
