# Consent Requests

## The ConsentRequest object

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `consentRequest`. |
| `id` | string | Yes | Unique identifier for the consent request. |
| `createdAt` | string | Yes | The timestamp at which the consent request was created. |
| `deliveryMethod` | null | emailLink | sms | smsLink | smsOTP | Yes | The method by which the consent request is delivered to the user. |
| `expiredAt` | null,string | Yes | The timestamp at which the consent request expired. |
| `operation` | change.phoneNumber | change.provider | exchange.sim | issue.portOutCredentials | portin.subscription | Yes | The operation being requested. |
| `status` | approved | bypassed | canceled | expired | pending | Yes | The status of the consent request. |
| `subject` | string | Yes | The ID of resource being affected by the operation. It can be for example a port out ID, if the operation is `issue.portOutCredentials`. |
| `subscription` | string | Yes | Unique identifier for the subscription inferred from the resource associated with this consent request, e.g. a port-out, porting, or subscription change. |

---

## List all consent requests

`GET /projects/{project}/consentRequests`

Returns a list of consent requests. The consent requests returned are sorted by creation date, with the most recently created consent requests appearing first.

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project` | string | Yes | The unique identifier for the [project](https://developers.gigs.com/core/projects#the-project-resource). |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `subject` | string | No | The unique identifier for the subject related to the consent request. |
| `subscription` | string | No | The unique identifier for the subscription related to the consent request. |
| `status` | string[] | No | A comma-separated list of statuses to filter the consent requests by. |
| `after` | string | No | A cursor for use in pagination. The `after` parameter takes an object ID that defines the position in the list, only items immediately following the item with that ID will be returned. |
| `before` | string | No | A cursor for use in pagination. The `before` parameter takes an object ID that defines the position in the list, only items immediately preceding the item with that ID will be returned. |
| `limit` | integer | No | The limit of items to be returned in the list, between 0 and 200. |

### Responses

#### 200 — Returns a list of consentRequest objects.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `list`. |
| `items` | object[] | Yes | List of objects of type `consentRequest`. |
| `moreItemsAfter` | string,null | Yes | A unique identifier to be used as `after` pagination parameter if more items are available sorted after the current batch of items. |
| `moreItemsBefore` | string,null | Yes | A unique identifier to be used as `before` pagination parameter if more items are available sorted before the current batch of items. |

#### 403 — The authenticated user doesn't have permissions to perform the request.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

#### 422 — The request can't be processed, often due to an invalid parameter or incompatible system state.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

---

## Create a consent request

`POST /projects/{project}/consentRequests`

Creates a new consent request from an existing one, delivering a new code to the user.
The existing consent request must be pending or
expired and must be the most recent one for its resource.
A pending one expires as soon as the new one is created.

### Body

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `fromConsentRequest` | string | Yes | The unique identifier for the existing consent request to recreate, e.g. when the user missed the original code. The new consent request covers the same operation and resource and carries a newly generated code. The referenced consent request must be `pending` or `expired` and must be the most recent one for its resource. A `pending` one expires as soon as the new one is created. |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project` | string | Yes | The unique identifier for the [project](https://developers.gigs.com/core/projects#the-project-resource). |

### Responses

#### 201 — Returns the created consent request.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `consentRequest`. |
| `id` | string | Yes | Unique identifier for the consent request. |
| `createdAt` | string | Yes | The timestamp at which the consent request was created. |
| `deliveryMethod` | null | emailLink | sms | smsLink | smsOTP | Yes | The method by which the consent request is delivered to the user. |
| `expiredAt` | null,string | Yes | The timestamp at which the consent request expired. |
| `operation` | change.phoneNumber | change.provider | exchange.sim | issue.portOutCredentials | portin.subscription | Yes | The operation being requested. |
| `status` | approved | bypassed | canceled | expired | pending | Yes | The status of the consent request. |
| `subject` | string | Yes | The ID of resource being affected by the operation. It can be for example a port out ID, if the operation is `issue.portOutCredentials`. |
| `subscription` | string | Yes | Unique identifier for the subscription inferred from the resource associated with this consent request, e.g. a port-out, porting, or subscription change. |

#### 403 — The authenticated user doesn't have permissions to perform the request.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

#### 404 — The requested resource doesn't exist.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

#### 422 — The request can't be processed, often due to an invalid parameter or incompatible system state.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

---

## Retrieve a consent request

`GET /projects/{project}/consentRequests/{consentRequest}`

Retrieves a consent request by the given id.

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project` | string | Yes | The unique identifier for the [project](https://developers.gigs.com/core/projects#the-project-resource). |
| `consentRequest` | string | Yes | The unique identifier of the consent request. |

### Responses

#### 200 — Returns the consent request if it exists.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `consentRequest`. |
| `id` | string | Yes | Unique identifier for the consent request. |
| `createdAt` | string | Yes | The timestamp at which the consent request was created. |
| `deliveryMethod` | null | emailLink | sms | smsLink | smsOTP | Yes | The method by which the consent request is delivered to the user. |
| `expiredAt` | null,string | Yes | The timestamp at which the consent request expired. |
| `operation` | change.phoneNumber | change.provider | exchange.sim | issue.portOutCredentials | portin.subscription | Yes | The operation being requested. |
| `status` | approved | bypassed | canceled | expired | pending | Yes | The status of the consent request. |
| `subject` | string | Yes | The ID of resource being affected by the operation. It can be for example a port out ID, if the operation is `issue.portOutCredentials`. |
| `subscription` | string | Yes | Unique identifier for the subscription inferred from the resource associated with this consent request, e.g. a port-out, porting, or subscription change. |

#### 403 — The authenticated user doesn't have permissions to perform the request.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

#### 404 — The requested resource doesn't exist.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

---

## Approves the consent request

`POST /projects/{project}/consentRequests/{consentRequest}/approve`

Grants consent for the given request. This will trigger the consent
request to be processed and the request to transition to the
approved status. The consent request must be
in the pending status in order to be approved.

### Body

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `code` | string | Yes | The OTP associated with the consent request, used to validate the given consent. |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project` | string | Yes | The unique identifier for the [project](https://developers.gigs.com/core/projects#the-project-resource). |
| `consentRequest` | string | Yes | The unique identifier of the consent request. |

### Responses

#### 200 — Returns the consent request.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `consentRequest`. |
| `id` | string | Yes | Unique identifier for the consent request. |
| `createdAt` | string | Yes | The timestamp at which the consent request was created. |
| `deliveryMethod` | null | emailLink | sms | smsLink | smsOTP | Yes | The method by which the consent request is delivered to the user. |
| `expiredAt` | null,string | Yes | The timestamp at which the consent request expired. |
| `operation` | change.phoneNumber | change.provider | exchange.sim | issue.portOutCredentials | portin.subscription | Yes | The operation being requested. |
| `status` | approved | bypassed | canceled | expired | pending | Yes | The status of the consent request. |
| `subject` | string | Yes | The ID of resource being affected by the operation. It can be for example a port out ID, if the operation is `issue.portOutCredentials`. |
| `subscription` | string | Yes | Unique identifier for the subscription inferred from the resource associated with this consent request, e.g. a port-out, porting, or subscription change. |

#### 403 — The authenticated user doesn't have permissions to perform the request.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

#### 404 — The requested resource doesn't exist.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

#### 422 — The request can't be processed, often due to an invalid parameter or incompatible system state.

| Property | Type | Required | Description |
|----------|------|----------|-------------|
| `object` | string | Yes | Type of object is always `error`. |
| `code` | string | No | An optional machine-readable description of the error. Present for errors that could be handled programmatically. |
| `details` | object[] | No | Optional array containing specific information for the current error.  <!-- theme: info --> > #### Preview > > This property is currently in preview and might change in the future. > > We’re excited to hear your feedback and ideas. Please send an email > to [support@gigs.com](mailto:support@gigs.com) to share your thoughts.  |
| `documentation` | string[] | No | An optional list of URLs providing further information to resolve the error. |
| `hint` | string | No | An optional explanation how to resolve the error. |
| `message` | string | Yes | A human readable description of the error. |
| `type` | string | Yes | The type of [error](https://developers.gigs.com/api/error-handling) returned. |

---
