***

title: Run a sale
published: true
---------------------

For clean Markdown of any page, append .md to the page URL. For a complete documentation index, see https://docs.payroc.com/essentials-guides/payroc-cloud/llms.txt. For full documentation content, see https://docs.payroc.com/essentials-guides/payroc-cloud/llms-full.txt.

After you configure a device for Payroc Cloud, program your POS to use the Submit Payment Instruction method to send a payment instruction to the payment device.

To take payment from a cardholder, complete the following:

1. Submit a payment instruction to the device.
2. View the status of the payment instruction.
3. View the details of the payment.

You can also cancel the payment instruction if it hasn’t yet completed.

### Before you begin

#### Bearer tokens

Use our Identity Service to generate a Bearer token to include in the header of your requests. To generate your Bearer token, complete the following steps:

1. Include your API key in the x-api-key parameter in the header of a POST request.
2. Send your request to [https://identity.payroc.com/authorize](https://identity.payroc.com/authorize).

<Note>
  **Note:** You need to generate a new Bearer token before the previous Bearer token expires.
</Note>

**Example request**

```bash
curl --location --request POST 'https://identity.payroc.com/authorize' --header 'x-api-key: <api key>'
```

**Example response**\
If your request is successful, we return a response that contains your Bearer token, information about its scope, and when it expires.

```json
{
  "access_token": "eyJhbGc....adQssw5c",
  "expires_in": 3600,
  "scope": "service_a service_b",
  "token_type": "Bearer"
}
```

#### Headers

To create the header of each POST request, you must include the following parameters:

* **Content-Type:** Include application/json as the value for this parameter.
* **Authorization:** Include your Bearer token in this parameter.
* **Idempotency-Key:** Include a UUID v4 to make the request idempotent.

```bash
curl
-H "Content-Type: application/json"
-H "Authorization: <Bearer token>"
-H "Idempotency-Key: <UUID v4>"
```

#### Errors

If your request is unsuccessful, we return an error. For more information about errors, see [Errors](/api/errors).

## Step 1. Submit a payment instruction

To submit a payment instruction to the device, send a POST request to the Devices endpoint.

| Endpoint   | Prefix   | URL                                                                         |
| ---------- | -------- | --------------------------------------------------------------------------- |
| Test       | api.uat. | `https://api.uat.payroc.com/v1/devices/{serialNumber}/payment-instructions` |
| Production | api.     | `https://api.payroc.com/v1/devices/{serialNumber}/payment-instructions`     |

### Request parameters

To create the body of your request, use the following parameters:

<EndpointSchemaSnippet endpoint="POST /devices/{serialNumber}/payment-instructions" selector="request.body" />

#### Example request

<EndpointRequestSnippet endpoint="POST /devices/{serialNumber}/payment-instructions" />

### Response fields

If your request is successful, we send the payment instruction to the device.

<Note>
  **Note:** The response returns a value of `inProgress` for the status field and an identifier for the instruction that you can use to check the status of the instruction. To get a link to view the details of the payment, go to Step 2.
</Note>

<EndpointSchemaSnippet endpoint="POST /devices/{serialNumber}/payment-instructions" selector="response.body" />

### Response parameters

<EndpointResponseSnippet endpoint="POST /devices/{serialNumber}/payment-instructions" example="paymentInstruction" />

## Step 2. View the status of a payment instruction

To check for updates to the status of the payment instruction, send a GET request to the Payment Instructions endpoint.

| Endpoint   | Prefix   | URL                                                                         |
| ---------- | -------- | --------------------------------------------------------------------------- |
| Test       | api.uat. | `https://api.uat.payroc.com/v1/payment-instructions/{paymentInstructionId}` |
| Production | api.     | `https://api.payroc.com/v1/payment-instructions/{paymentInstructionId}`     |

Before our gateway sends a response, it waits for up to a minute for the status of the instruction to change. We recommend that you keep the session open until the status of the instruction changes or the request times out.

If the status of the instruction doesn’t change, send another GET request. Our gateway waits up to a minute for the status of the instruction to change. Continue to send GET requests until the status changes.

<Note>
  **Note:** Wait until you receive a response from our gateway before you send another request.
</Note>

### Request parameters

To create your request, use the following parameters:

<EndpointSchemaSnippet endpoint="GET /payment-instructions/{paymentInstructionId}" selector="request.path" />

#### Example request

<EndpointRequestSnippet endpoint="GET /payment-instructions/{paymentInstructionId}" />

### Response fields

If your request is successful, we return the details of the payment instruction, including HATEOAS links to check the details of the payment. Use the HATEOAS links to get the paymentId, which you need in Step 3.

If the status of the payment instruction is `inProgress`, our gateway waits up to a minute for the status to change before it returns a response.

<EndpointSchemaSnippet endpoint="GET /payment-instructions/{paymentInstructionId}" selector="response.body" />

#### Example response

<EndpointResponseSnippet endpoint="GET /payment-instructions/{paymentInstructionId}" example="Retrieved" />

## Step 3. View the details of the payment

To check whether the processor approved or declined the payment, send a GET request to the Payments endpoint.

| Endpoint   | Prefix   | URL                                                  |
| ---------- | -------- | ---------------------------------------------------- |
| Test       | api.uat. | `https://api.uat.payroc.com/v1/payments/{paymentId}` |
| Production | api.     | `https://api.payroc.com/v1/payments/{paymentId}`     |

### Request parameters

To create your request, use the following parameters:

<EndpointSchemaSnippet endpoint="GET /payments/{paymentId}" selector="request.path" />

#### Example request

<EndpointRequestSnippet endpoint="GET /payments/{paymentId}" />

### Response fields

If your request is successful, we return the details of the payment.

<EndpointSchemaSnippet endpoint="GET /payments/{paymentId}" selector="response.body" />

#### Example response

<EndpointResponseSnippet endpoint="GET /payments/{paymentId}" example="Retrieved" />

## (Optional) Cancel a payment instruction

To cancel a payment instruction, send a DELETE request to the Payment Instructions endpoint.

| Endpoint   | Prefix   | URL                                                                         |
| ---------- | -------- | --------------------------------------------------------------------------- |
| Test       | api.uat. | `https://api.uat.payroc.com/v1/payment-instructions/{paymentInstructionId}` |
| Production | api.     | `https://api.payroc.com/v1/payment-instructions/{paymentInstructionId}`     |

<Note>
  **Note:** You can cancel a payment instruction only if its status is `inProgress`.
</Note>

### Request parameters

To create your request, use the following parameters:

<EndpointSchemaSnippet endpoint="DELETE /payment-instructions/{paymentInstructionId}" selector="request.path" />

#### Example request

<EndpointSchemaSnippet endpoint="DELETE /payment-instructions/{paymentInstructionId}" />

### Response fields

If your request is successful, we cancel the payment instruction.