> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/rest-api/identity-api/identity-api-reference/tracking/finish-tracking.md).

# Finish Tracking

This service completes the tracking process and must be invoked at the end of all validations in the Onboarding or Authentication flows. **When this service is integrated, it is not necessary to invoke the closeSession method of the SDK Mobile/Web.**

### Endpoint

```
POST /services/finishTracking
```

### Headers

| Name          | Type   | Required | Description                                                                                             |
| ------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------- |
| **x-api-key** | string | **Yes**  | Access authorization API key.                                                                           |
| **family**    | string | No       | Value: **Onboarding** or **Authentication**, depending on the Flow. Required with the tracking service. |

{% hint style="info" %}
All calls to the Endpoints for Tracking with **Identity Platform** must contain the header `family`.
{% endhint %}

### Request body

**Content-Type:** `application/json`

#### Parameters

| Parameter   | Type   | Required | Description                                                                                     |
| ----------- | ------ | -------- | ----------------------------------------------------------------------------------------------- |
| `family`    | string | **Yes**  | Possible values: **Authentication**, **Onboarding**                                             |
| `status`    | string | **Yes**  | Possible values: **SUCCEEDED**, **DENIED**, **ERROR**, **CANCELLED**, **BLACKLISTED**           |
| `reason`    | string | **Yes**  | Reason for the tracking result. See [possible values of `reason`](#valores-posibles-de-reason). |
| `extraData` | string | **Yes**  | Token generated by the SDK Mobile/Web. Contains tokenized tracking information.                 |

#### Possible values of `reason`

| Value                              | Description                               |
| ---------------------------------- | ----------------------------------------- |
| `""`                               | No specific reason (successful operation) |
| `DOCUMENT_VALIDATION_NOT_PASSED`   | The document validation was not passed    |
| `DOCUMENT_VALIDATION_ERROR`        | Error during document validation          |
| `FACIAL_AUTHENTICATION_NOT_PASSED` | Facial authentication was not passed      |
| `FACIAL_LIVENESS_NOT_PASSED`       | Facial liveness check was not passed      |
| `FACIAL_AUTHENTICATION_ERROR`      | Error during facial authentication        |
| `FACIAL_LIVENESS_ERROR`            | Error during facial liveness check        |
| `BLACKLISTED_FACE_TEMPLATE`        | The facial template is on the blacklist   |
| `ALREADY_REGISTERED`               | The user is already registered            |
| `MANUAL_STATUS_CHANGE`             | Manual status change                      |
| `SECURITY_SERVICE_ERROR`           | Error in the security service             |
| `SELPHID_INTERNAL_ERROR`           | Internal SelphID error                    |
| `SELPHID_TIMEOUT`                  | SelphID Timeout                           |
| `SELPHI_TIMEOUT`                   | Selphi Timeout                            |

#### Request example

```json
{
  "family": "OnBoarding",
  "status": "SUCCEEDED",
  "reason": "MANUAL_STATUS_CHANGE",
  "extraData": "BQABAQG2gBNjuHN4kLmPqYf7R..."
}
```

### Responses

#### `200` Success

#### Response parameters

| Parameter         | Type    | Description                                                                                                                                                  |
| ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `trackingStatus`  | integer | Code that indicates the result of the execution of the tracking service. The value **201** indicates the service was processed without exceptions.           |
| `trackingMessage` | string  | Message that indicates the result of the execution of the tracking service. The value **"FinishTrackingEvent: Ok"** indicates processing without exceptions. |
| `transactionId`   | string  | Transaction identifier associated with the request processed by the API.                                                                                     |
| `timestamp`       | string  | Timestamp (UTC) of the response in format YYYY-MM-DDThh:flag\_mm:ss.SSSZ                                                                                     |

#### Response example

```json
{
  "trackingStatus": 201,
  "trackingMessage": "FinishTrackingEvent: Ok",
  "transactionId": "123e4567-e89b-12d3-a456-426614174000",
  "timestamp": "2023-05-01T12:34:56.789Z"
}
```

#### `400` Bad Request

```json
{
  "status": 400,
  "title": "Bad Request",
  "detail": "Invalid request.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400",
  "errors": []
}
```

#### `401` Unauthorized

```json
{
  "message": "Unauthorized"
}
```

#### `403` Forbidden

```json
{
  "Message": "User is not authorized to access this resource with an explicit deny"
}
```

#### `502` Bad Gateway

```json
{
  "status": 502,
  "title": "Bad Gateway",
  "detail": "Server got an invalid response.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502"
}
```

#### `504` Gateway Timeout

```json
{
  "message": "Endpoint request timed out"
}
```
