# Get PCSID Generation Status

Gets status of the PCSID generation activity.

### Request Method

GET

### Request URL

```
{{BASE_URL}}/onboarding/{ActivityId}/pcsid-status
```

{% hint style="info" %}
Replace the `{{BASE_URL}}` with the one mentioned [here](..) based on whether you are using sandbox or production.
{% endhint %}

### Request Headers

| Parameter             | Data Type | Field Validations | Description                                                                                                 |
| --------------------- | --------- | ----------------- | ----------------------------------------------------------------------------------------------------------- |
| x-cleartax-auth-token | String    | Cannot be empty.  | Mandatory. [User auth token](../../learn-e-invoicing-ksa-api-basics/how-to-get-e-invoicing-ksa-auth-token). |
| vat                   | String    | Cannot be empty   | Mandatory. VAT or Group VAT of the entity.                                                                  |

### Request Path Params

| Parameter  | Data Type | Field Validations | Description                                                              |
| ---------- | --------- | ----------------- | ------------------------------------------------------------------------ |
| ActivityId | String    | UUID              | Mandatory. The `PcsidGenerationActivityId` received in the previous API. |

### Request Query Params

There are no query parameters for this API.

### Request Body

There is no request body for this API.

### Sample Request

```
https://api-sandbox.cleartax.com/middle-east/ksa/einvoicing/onboarding/628f37b61ed71a6638b848e4/pcsid-status
```

### Response Status Codes

| HTTP Status Code | Description                                         |
| ---------------- | --------------------------------------------------- |
| 200              | For a successful status retrieval.                  |
| 400              | For any kind of validation issues.                  |
| 401              | If the user is not authenticated for the operation. |
| 403              | If the user is not authorized for the operation.    |

### Response Schema

| Parameter       | Data Type | Field Validations                                              | Description                                                                                                                                                                                 |
| --------------- | --------- | -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ActivityType    | String    | NA                                                             | Mandatory. Activity type of the async activity. This will always be ZATCA\_COMPLIANCE\_INVOICE.                                                                                             |
| Status          | String    | <p>Enum:</p><p>IN_PROGRESS,</p><p>SUCCEEDED, </p><p>FAILED</p> | <p>Mandatory. The status of the entire asnc activity.<br><br>IN_PROGRESS - PCSID generation is in progress. SUCCEEDED - PCSID generation is complete. FAILED - PCSID generation failed.</p> |
| CreatedAt       | String    | Timestamp (UTC)                                                | Mandatory. When the async activity was created.                                                                                                                                             |
| UpdatedAt       | String    | Timestamp (UTC)                                                | Mandatory. When the async activity was last updated.                                                                                                                                        |
| CompletedAt     | String    | Timestamp (UTC)                                                | <p>Mandatory. When the async activity was completed.</p><p>If the state is IN_PROGRESS, the value will be null.</p>                                                                         |
| RequestMetaInfo | Object    | NA                                                             | Request Meta Info Object.                                                                                                                                                                   |
| ResponseInfo    | Object    | NA                                                             | Response Info Object.                                                                                                                                                                       |
| ErrorList       | Array     | NA                                                             | Optional. Array of [Error Details objects](../resources-and-masters/error-details-object).                                                                                                  |

#### Request Meta Info Object

| Parameter    | Data Type | Field Validations                        | Description                                                                                                                                                                                                                                                |
| ------------ | --------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| TotalCount   | Number    | NA                                       | Mandatory. Always 6. 6 indicates the number of compliance checks done.                                                                                                                                                                                     |
| SuccessCount | Number    | Will be less than or equal to TotalCount | <p>Mandatory. Number of compliance checks, mentioned above, that passed. </p><p></p><p>This will be updated only after the entire activity is completed.</p>                                                                                               |
| FailureCount | Number    | Will be less than or equal to TotalCount | <p>Mandatory. Number of compliance checks, mentioned above, that failed. This deals with all errors (zatca/CT server 5xx failure + compliance checks or 4xx failures). </p><p></p><p>This will be updated only after the entire activity is completed.</p> |

#### Response Info Object

| Parameter        | Data Type | Field Validations | Description                                                                        |
| ---------------- | --------- | ----------------- | ---------------------------------------------------------------------------------- |
| ResponseMetaData | Object    | NA                | Optional. ResponseMetaData Object. This will be NULL when activity is IN\_PROGRESS |

#### Response Metadata Object

| Parameter                  | Data Type | Field Validations                            | Description                                                                                          |
| -------------------------- | --------- | -------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
| PcsidGenerated             | String    | <p>Enum: </p><p>GENERATED, </p><p>FAILED</p> | Mandatory. Final PCSID generation status. This is dependent on the 6 compliance checks listed below. |
| StandardTaxInvoice         | String    | SUCCEEDED/ comma separated error messages    | Optional. State of compliance check for Standard Tax Invoice.                                        |
| StandardTaxInvoiceCredit   | String    | SUCCEEDED/ comma separated error messages    | Optional. State of compliance check for Standard Tax Invoice - Credit Note.                          |
| StandardTaxInvoiceDebit    | String    | SUCCEEDED/ comma separated error messages    | Optional. State of compliance check for Standard Tax Invoice - Debit Note.                           |
| SimplifiedTaxInvoice       | String    | SUCCEEDED/ comma separated error messages    | Optional. State of compliance check for Simplified Tax Invoic                                        |
| SimplifiedTaxInvoiceCredit | String    | SUCCEEDED/ comma separated error messages    | Optional. State of compliance check for Simplified Tax Invoice - Credit Note.                        |
| SimplifiedTaxInvoiceDebit  | String    | SUCCEEDED/ comma separated error messages    | Optional. State of compliance check for Simplified Tax Invoice - Debit Note.                         |

### Sample Response

In Progress State - HTTP Status Code - 200

```json
{
    "ActivityType": "ZATCA_COMPLIANCE_INVOICE",
    "Status": "IN_PROGRESS",
    "CreatedAt": "2022-05-20 18:56:11",
    "UpdatedAt": "2022-05-20 18:56:11",
    "CompletedAt": null,
    "RequestMetaInfo": {
        "TotalCount": 6,
        "SuccessCount": null,
        "FailureCount": null
    },
    "ResponseInfo": {
        "ResponseMetaData": null
    }
}
```

Succeeded State - HTTP Status Code - 200

```json
{
    "ActivityType": "ZATCA_COMPLIANCE_INVOICE",
    "Status": "SUCCEEDED",
    "CreatedAt": "2022-05-20 18:56:11",
    "UpdatedAt": "2022-05-20 18:56:20",
    "CompletedAt": "2022-05-20 18:56:20",
    "RequestMetaInfo": {
        "TotalCount": 6,
        "SuccessCount": 6,
        "FailureCount": 0
    },
    "ResponseInfo": {
        "ResponseMetaData": {
            "PcsidGenerated": "GENERATED",
            "StandardTaxInvoice": "SUCCEEDED",
            "StandardTaxInvoiceCredit": "SUCCEEDED",
            "StandardTaxInvoiceDebit": "SUCCEEDED",
            "SimplifiedTaxInvoice": "SUCCEEDED",
            "SimplifiedTaxInvoiceCredit": "SUCCEEDED",
            "SimplifiedTaxInvoiceDebit": "SUCCEEDED"
        }
    }
}
```

Failed state - HTTP Status Code - 500

```json
{
    "ActivityType": "ZATCA_COMPLIANCE_INVOICE",
    "Status": "FAILED",
    "CreatedAt": "2022-06-01 14:46:49",
    "UpdatedAt": "2022-06-01 14:46:49",
    "CompletedAt": "2022-06-01 14:46:49",
    "RequestMetaInfo": {
        "TotalCount": 6,
        "SuccessCount": 0,
        "FailureCount": 6
    },
    "ResponseInfo": {
        "ResponseMetaData": null
    }
}
```

Error - HTTP Status Code - 400

```json
{
    "Status": "FAILED",
    "ErrorList": [
        {
            "ErrorCode": "6003",
            "ErrorMessage": "The async activity was not found",
            "ErrorSource": "CLEARTAX"
        }
    ]
}
```

### API Validations

1. The `ActivityId` should be valid and must be related to PCSID generation only.

### API Constraints

1. This API needs to be authenticated with a valid user authentication token. If the auth token is not present or is invalid, the API will return HTTP Status Code 401.
2. If the auth token is valid, but the user does not have the authorization to generate device ID, then the API will return HTTP Status Code 403. The user, whose auth token is used, should have an Admin role for the particular VAT used in the request.
