# Export users

Export users from a workspace.

```
GET https://api.croct.io/export/user
```

## Example

Here is an example of how to export users:

**JavaScript**

```js
const url = new URL('https://api.croct.io/export/user');
url.searchParams.append('start', '1440990000000');
url.searchParams.append('end', '1441076400000');
url.searchParams.append('pageSize', '100');

const response = await fetch(url, {
  headers: {
    'X-Api-Key': '<API KEY>',
  },
});

const {items, nextCursor} = await response.json();
```

**cURL**

```bash
curl -X GET 'https://api.croct.io/export/user' \
  -H 'X-Api-Key: <API KEY>' \
  -G \
  --data-urlencode 'start=1440990000000' \
  --data-urlencode 'end=1441076400000' \
  --data-urlencode 'pageSize=100'
```

## Headers

This endpoint requires the following HTTP headers:

- `X-Api-Key`: `string`

  The [API key](/explanation/application/api-keys) of the application associated with the workspace from which to export users.

## Parameters

This endpoint accepts the following query parameters:

- `start`: `integer` (optional)

  The earliest user last-modified time to include, in milliseconds since epoch.

  Only users updated at or after this time are included.

- `end`: `integer` (optional)

  The latest user last-modified time to include, in milliseconds since epoch.

  Only users updated before this time are included. If not provided, there is no upper time limit.

- `pageSize`: `integer` (optional) (default: 100)

  The maximum number of users returned per request.

  Must be between 1 and 1000.

- `cursor`: `string` (optional)

  A cursor for retrieving the next page of results.

  If omitted, export starts from the beginning of the specified time window.

## Response

This endpoint returns a JSON response with the following properties:

- `data`: `object`

  The response containing exported users and pagination information.

  - `items`: `Array<object>`

    The list of exported users.

    - `userId`: `string`

      The internal ID assigned to the user, unique across the workspace, in UUID format.

    - `externalUserId`: `string|null`

      The external user ID used to identify the user on the application side.

      Always `null` for anonymous users.

    - `firstName`: `string|null`

      The user's first name.

    - `lastName`: `string|null`

      The user's last name.

    - `birthDate`: `integer|null`

      The user's birth date, in milliseconds since epoch.

    - `gender`: `string`

      The user's gender.

      These are the possible values and what they represent:

      | Value     | Description                     |
      | --------- | ------------------------------- |
      | `MALE`    | Male gender.                    |
      | `FEMALE`  | Female gender.                  |
      | `NEUTRAL` | Neither male nor female gender. |
      | `UNKNOWN` | An unspecified gender.          |

    - `email`: `string|null`

      The user's primary email address.

    - `alternateEmail`: `string|null`

      The user's alternate email address.

    - `phone`: `string|null`

      The user's primary phone number.

    - `alternatePhone`: `string|null`

      The user's alternate phone number.

    - `address`: `UserAddress`

      The user's address information.

      - `street`: `string|null`

        Street address.

      - `district`: `string|null`

        District or neighborhood.

      - `city`: `string|null`

        City name.

      - `region`: `string|null`

        State or region.

      - `country`: `string|null`

        Country name.

      - `postalCode`: `string|null`

        Postal or ZIP code.

    - `avatar`: `string|null`

      The URL of the user's avatar image.

    - `company`: `string|null`

      The user's company name.

    - `companyUrl`: `string|null`

      The user's company website URL.

    - `jobTitle`: `string|null`

      The user's job title.

    - `activities`: `Array<string>`

      The user's activities.

    - `interests`: `Array<string>`

      The user's interests.

    - `customAttributes`: `object`

      Custom attributes associated with the user.

    - `lastModifiedTime`: `integer`

      The timestamp when the user was last modified, in milliseconds since epoch.

      Not updated on sync operations.

    - `statistics`: `UserStatistics`

      Aggregated user statistics across the workspace.

      - `orders`: `integer`

        The total number of orders placed across all applications.

      - `sessions`: `integer`

        The total number of sessions across all applications.

  - `nextCursor`: `string`

    An opaque cursor for retrieving the next page of results.

    The value is an empty string when there are no more results. Treat it as opaque and pass it back unchanged on the next request.

### Example response

Here is an example of a JSON response from this endpoint:

```json
{
  "items": [
    {
      "userId": "e9fc50b8-1773-42a0-ac51-fab9a1ee48de",
      "externalUserId": "john-doe-acme-123",
      "firstName": "John",
      "lastName": "Doe",
      "birthDate": 631152000000,
      "gender": "MALE",
      "email": "john@acme.com",
      "alternateEmail": "john@example.com",
      "phone": "000000000",
      "alternatePhone": "999999999",
      "address": {
        "street": "Av. Paulista, 2202",
        "district": "Bela Vista",
        "city": "São Paulo",
        "region": "São Paulo",
        "country": "BR",
        "postalCode": "12345-678"
      },
      "avatar": "https://example.com/avatar",
      "company": "Acme",
      "companyUrl": "https://acme.com",
      "jobTitle": "CEO",
      "activities": ["content-share", "newsletter-subscription"],
      "interests": ["business", "politics"],
      "customAttributes": {
        "plan": "Pro",
        "subscriptionDate": "2025-01-01"
      },
      "lastModifiedTime": 1440979201000,
      "statistics": {
        "orders": 2,
        "sessions": 1
      }
    }
  ],
  "nextCursor": "eyJzZXNzaW9uSWQiOiIxMjM0NSIsImNsb3NlVGltZSI6MTYwOTQ1OTMwMDAwMH0"
}
```
