# Redirect Flow

Source: https://docs.gocardless.com/docs/api-reference/redirect-flow

## Create a redirect flow

`POST /redirect_flows`

Creates a redirect flow object which can then be used to redirect your customer to the GoCardless hosted payment pages.

**Deprecated:** Redirect Flows are legacy APIs and cannot be used by new integrators.
The [Billing Request flow](#billing-requests) API should be used for your payment flows.

### Request body

Wrap request body attributes in a `redirect_flows` object.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `description` | string | No | A description of the item the customer is paying for. This will be shown on the hosted payment pages. |
| `session_token` | string | No | The customer's session ID must be provided when the redirect flow is set up and again when it is completed. This allows integrators to ensure that the user who was originally sent to the GoCardless payment pages is the one who has completed them. |
| `scheme` | string | No | The Direct Debit scheme of the mandate. If specified, the payment pages will only allow the set-up of a mandate for the specified scheme. It is recommended that you leave this blank so the most appropriate scheme is picked based on the customer's bank account. |
| `success_redirect_url` | string | No | The URL to redirect to upon successful mandate setup. You must use a URL beginning `https` in the live environment. |
| `prefilled_customer` | object | No | Customer information used to prefill the payment page so your customer doesn't have to re-type details you already hold about them. It will be stored unvalidated and the customer will be able to review and amend it before completing the form. |
| `prefilled_bank_account` | object | No | Bank account information used to prefill the payment page so your customer doesn't have to re-type details you already hold about them. It will be stored unvalidated and the customer will be able to review and amend it before completing the form. |
| `links` | object | No |  |
| `metadata` | object | No | Key-value store of custom data. Up to 3 keys are permitted, with key names up to 50 characters and values up to 500 characters. _Note:_ This should not be used for storing PII data. |

### Responses

| Status | Description |
| --- | --- |
| 201 | Resource created successfully |
| 400 | Bad Request |
| 401 | Unauthorised |
| 404 | Not found |
| 422 | Validation Error |
| 500 | Internal Error |

---

## Get a single redirect flow

`GET /redirect_flows/{redirect_flow_id}`

Returns all details about a single redirect flow

**Deprecated:** Redirect Flows are legacy APIs and cannot be used by new integrators.
The [Billing Request flow](#billing-requests) API should be used for your payment flows.

### Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `redirect_flow_id` | path | string | Yes | The redirect flow id |

### Responses

| Status | Description |
| --- | --- |
| 200 | Successful response |
| 400 | Bad Request |
| 401 | Unauthorised |
| 404 | Not found |
| 422 | Validation Error |
| 500 | Internal Error |

---

## Complete a redirect flow

`POST /redirect_flows/{redirect_flow_id}/actions/complete`

This creates a [customer](#core-endpoints-customers), [customer bank account](#core-endpoints-customer-bank-accounts), and [mandate](#core-endpoints-mandates) using the details supplied by your customer and returns the ID of the created mandate.

This will return a `redirect_flow_incomplete` error if your customer has not yet been redirected back to your site, and a `redirect_flow_already_completed` error if your integration has already completed this flow. It will return a `bad_request` error if the `session_token` differs to the one supplied when the redirect flow was created.

**Deprecated:** Redirect Flows are legacy APIs and cannot be used by new integrators.
The [Billing Request flow](#billing-requests) API should be used for your payment flows.

### Parameters

| Name | Location | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `redirect_flow_id` | path | string | Yes | The redirect flow id |

### Request body

Wrap request body attributes in a `redirect_flows` object.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `session_token` | string | No | The customer's session ID must be provided when the redirect flow is set up and again when it is completed. This allows integrators to ensure that the user who was originally sent to the GoCardless payment pages is the one who has completed them. |

### Responses

| Status | Description |
| --- | --- |
| 200 | Action completed successfully |
| 400 | Bad Request |
| 401 | Unauthorised |
| 404 | Not found |
| 422 | Validation Error |
| 500 | Internal Error |
