# Export user by ID

Export a single user by ID.

```
GET https://api.croct.io/export/user/6d5f1fe8-3f21-4bce-9afb-e1d11b610674
```

## Example

Here is an example of how to export a single user by ID:

**JavaScript**

```js
const userId = '6d5f1fe8-3f21-4bce-9afb-e1d11b610674';
const url = new URL(`https://api.croct.io/export/user/${userId}`);

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

const user = await response.json();
```

**cURL**

```bash
curl -X GET 'https://api.croct.io/export/user/6d5f1fe8-3f21-4bce-9afb-e1d11b610674' \
  -H 'X-Api-Key: <API KEY>'
```

## 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 the user.

## Parameters

This endpoint accepts the following path parameters:

- `userId`: `string`

  The ID of the user in UUID format.

## Response

This endpoint returns a JSON response with the following properties:

- `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.

### Example response

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

```json
{
  "userId": "6d5f1fe8-3f21-4bce-9afb-e1d11b610674",
  "externalUserId": "d9e7908f-791a-4c4a-89ac-234502b8f817",
  "firstName": "Erick",
  "lastName": "Doe",
  "birthDate": 1440892800000,
  "gender": "MALE",
  "email": "erick.doe@croct.com",
  "alternateEmail": "erick.doe@gmail.com",
  "phone": "+5511999999999",
  "alternatePhone": "+551133333333",
  "address": {
    "street": "Rua Fidêncio Ramos",
    "district": "Vila Olímpia",
    "city": "São Paulo",
    "region": "São Paulo",
    "country": "BR",
    "postalCode": "04551-010"
  },
  "avatar": "https://croct.com/erick.png",
  "company": "Croct",
  "companyUrl": "https://croct.com",
  "jobTitle": "Developer",
  "activities": ["clicked-banner"],
  "interests": ["credit-card"],
  "customAttributes": {
    "plan": "Pro",
    "subscriptionDate": "2025-01-01"
  },
  "lastModifiedTime": 1440979201000,
  "statistics": {
    "orders": 10,
    "sessions": 200
  }
}
```

If no user matches the given ID, the endpoint responds with a [resource not found](/reference/api/error/resource-not-found) error.
