# Cancel Sign Request

This endpoint allows RP to initiate a cancellation to a sign request. RP can cancel any active or expired sign requests created by them.

A cancellation request will be rejected if **any** of the following conditions are met:

* The user has already initiated a sign session (clicked *Proceed to Sign* and signing QR code is shown)&#x20;
* The document has already been signed
* The sign request has already been cancelled

### Path <a href="#path" id="path"></a>

<mark style="color:green;">`POST`</mark> `/sign-requests/cancel`

### Headers <a href="#headers" id="headers"></a>

| Name          | Value            |
| ------------- | ---------------- |
| Content-Type  | application/json |
| Authorization | \<token>         |

## Authorization token

RP should sign the signature parameter into a JWT token as authorization token.

* **Token Type:** Standard JWT ([JSON Web Token](https://datatracker.ietf.org/doc/html/rfc7519))
* **Payload:**
  * `request_id`: Same as the request id returned during initiate sign request
  * `client_request`: Your application's registered client ID
  * `iat` & `exp`: Standard Issued At / Expiration timestamp of JWT. Must issued within 2 minutes.

Example:

{% code overflow="wrap" %}

```
eyJhbGciOiJFUzI1NiIsImtpZCI6InBUaHpVbl9JNVJXZzcyQWEyUzI1LXhoRG0wRzBNWjNSN3FpWUdyYmVmT0EifQ.eyJjbGllbnRfaWQiOiJ0ZXN0LWNsaWVudC1pZCIsInJlcXVlc3RfaWQiOiJzaWdudjMtMDE5OWNjOWMtOGI3Yy03MGRmLWIyOWItMzk4NDNhMTBjMzMyIiwiaWF0IjoxNzYwMDc0NDkxLCJleHAiOjE3NjAwNzQ2MTF9.-mf63KNiCCKNuVgAwn7OL4Lv7vnZ9fvPT5Pm2lCWQn36k6SK5jkBm8Iwonr0Yg5cTb1Jf2T1DK5aG_1VzYkqig
```

{% endcode %}

## Body

Empty

## Response

{% tabs %}
{% tab title="Cancelled (200)" %}

* `200 OK` Sign request successfully cancelled
  {% endtab %}

{% tab title="Active Session (400)" %}

```
{
  'error': 'ACTIVE_SESSION_ONGOING'
  'error_description': 'Request cannot be cancelled due to an active sign session'
}
```

* The user has already initiated a sign session (clicked *Proceed to Sign*)
* RP will not be able to cancel and will receive `400 Bad Request`
  {% endtab %}

{% tab title="Request Signed (400)" %}

```
{
  'error': 'DOCUMENT_ALREADY_SIGNED'
  'error_description': 'Document has already been signed'
}
```

* The document has already been signed
* RP will not be able to cancel and will receive `400 Bad Request`
  {% endtab %}

{% tab title="Request Cancelled (400)" %}

```
{
  'error': 'REQUEST_ALREADY_CANCELLED'
  'error_description': 'Document has already been cancelled'
}
```

* The sign request has already been cancelled
* RP will not be able to cancel and will receive `400 Bad Request`
  {% endtab %}

{% tab title="Invalid Request ID" %}

```
{
  'error': 'CLIENT_SIDE_ERROR'
  'error_description': 'No record found'
}
```

* If the request\_id is invalid or not found, RP will receive `400 Bad Request` .
  {% endtab %}
  {% endtabs %}

### Sample Request <a href="#sample-request" id="sample-request"></a>

```sh
curl -X POST http://staging.sign.singpass.gov.sg/api/v3/sign-requests/cancel \
  -H "Authorization: eyJhbGciOiJFUzI1NiIsImtpZCI6InBUaHpVbl9JNVJXZzcyQWEyUzI1LXhoRG0wRzBNWjNSN3FpWUdyYmVmT0EifQ.eyJjbGllbnRfaWQiOiJ0ZXN0LWNsaWVudC1pZCIsInJlcXVlc3RfaWQiOiJzaWdudjMtMDE5OWNjOWMtOGI3Yy03MGRmLWIyOWItMzk4NDNhMTBjMzMyIiwiaWF0IjoxNzYwMDc0NDkxLCJleHAiOjE3NjAwNzQ2MTF9.-mf63KNiCCKNuVgAwn7OL4Lv7vnZ9fvPT5Pm2lCWQn36k6SK5jkBm8Iwonr0Yg5cTb1Jf2T1DK5aG_1VzYkqig" \
  -H "Content-Type: application/json"

```
