> 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/country-integrations/chile/previred/create-previred-transaction.md).

# Create Previred Transaction

Service that starts the complete Integration Flow with Previred and returns a transaction identifier.

This service processes all Previred validation data, generates the evidence and compliance documentation, and returns a transaction ID that can be used to retrieve the generated Token and the evidence documents.

### Prerequisites

Before calling this service, you need to have:

* A `serviceTransactionId` valid one obtained by calling `/onboarding/v2/identity`.
* A `scanReference` valid one obtained by calling `/verify/documentValidation/v2/start`.

### Endpoint

```
POST /services/previred
```

### Headers

| Name          | Type   | Required | Description                   |
| ------------- | ------ | -------- | ----------------------------- |
| **x-api-key** | string | **Yes**  | Access authorization API Key. |

### Request body

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

#### Parameters

| Parameter                         | Type   | Required | Description                                                             |
| --------------------------------- | ------ | -------- | ----------------------------------------------------------------------- |
| `customerId`                      | string | **Yes**  | Customer ID assigned to the institution making the request.             |
| `identityTransactionId`           | string | **Yes**  | Identifier returned when calling `/v2/identity`.                        |
| `documentValidationScanReference` | string | **Yes**  | Identifier returned when calling `/verify/documentValidation/v2/start`. |
| `ipVerified`                      | string | **Yes**  | IP address of the Identity Verification Endpoint.                       |
| `callbackUrl`                     | string | No       | Optional callback URL for transaction completion notifications.         |

#### Request example

```json
{
  "customerId": "customer_123",
  "identityTransactionId": "2db602ee-3564-4304-af95-92a52eaae12d",
  "documentValidationScanReference": "doc_scan_456",
  "ipVerified": "192.168.1.100",
  "callbackUrl": "https://example.com/callback"
}
```

### Responses

#### `200` Success

#### Response parameters

| Parameter       | Type    | Description                                                                 |
| --------------- | ------- | --------------------------------------------------------------------------- |
| `timestamp`     | integer | Unix timestamp of the response in seconds.                                  |
| `transactionId` | string  | Transaction ID linked to the evidence generation process.                   |
| `hash`          | string  | Control string of the message received by the service (informational data). |

#### Response example

```json
{
  "timestamp": 1709708084,
  "transactionId": "0fec0e8d-3ef3-477f-ae9e-e350cda74b33",
  "hash": "61cf9b68412783c57dd5a9b0ca702a0902d81054"
}
```

#### `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"
}
```

#### `404` Not Found

```json
{
  "status": 404,
  "title": "Not Found",
  "detail": "Transaction not found.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404"
}
```

#### `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"
}
```
