# Responses

vrtx follows modern REST API standards to ensure consistent responses across all endpoints.
Both success and error responses follow a structured JSON format for easier parsing, logging, and debugging.

---

## <Icon icon="material-outline-check_circle_outline"/> Success Responses (2xx)

| Code    | Status     | Meaning                                                    |
| ------- | ---------- | ---------------------------------------------------------- |
| **200** | Success    | The request completed successfully.                        |
| **201** | Created    | A new resource was successfully created or inserted.       |
| **202** | Accepted   | The request has been accepted for asynchronous processing. |
| **204** | No Content | The operation succeeded, but no content is returned.       |

---

## <Icon icon="material-outline-cancel"/> Error Responses (4xx / 5xx)

All vrtx errors follow this structure:

```json
{
  "errorCode": "INVALID_INPUT",
  "errorMessage": "Input parameters failed validation",
  "details": [
    {
      "fieldName": "newPin",
      "description": "The PIN you provided is weak. PIN must be 4 digits, does not have serial digits or repeated digits.",
      "code": "invalid_string"
    }
  ],
  "statusCode": 400
}
```

---

### Error Codes

| Status  | Error Code      | Meaning                                                        |
| ------- | --------------------- | -------------------------------------------------------------- |
| **400** | `INVALID_INPUT`       | Request contains invalid or missing parameters.                |
| **401** | `UNAUTHORIZED`        | Invalid or missing credentials (API key, secret, or token).    |
| **403** | `FORBIDDEN`           | Request understood but permissions/scopes do not allow action. |
| **404** | `NOT_FOUND`           | The requested resource or endpoint does not exist.             |
| **405** | `METHOD_NOT_ALLOWED`  | HTTP method not supported for this endpoint.                   |
| **406** | `NOT_ACCEPTABLE`      | The request format or encoding is not supported.               |
| **410** | `GONE`                | The resource existed previously but is no longer available.    |
| **422** | `VALIDATION_FAILED`   | Body is well-formed but semantic validation failed.            |
| **429** | `RATE_LIMIT_EXCEEDED` | Too many requests in a short timeframe.                        |
| **500** | `INTERNAL_ERROR`      | Unexpected internal server error.                              |
| **503** | `SERVICE_UNAVAILABLE` | Temporary downtime or maintenance window.                      |

---

### Scenarios
<AccordionGroup>
<Accordion title="Unauthorized Scenarios (401)" defaultOpen>
    These occur with the following scenarios:
    <Steps>
      <Step title="Invalid or Missing Credentials">  </Step>
      <Step title="Invalid or Expired Access Token">  </Step>
      <Step title="Token Revoked">  </Step>
      <Step title="Wrong Environment Token (Sandbox vs Production)">  </Step>
    </Steps>
```js
{
  "errorCode": "UNAUTHORIZED",
  "errorMessage": "Invalid authorization token",
  "details": [],
  "statusCode": 401
}
```
</Accordion>
    
    <Accordion title="Forbidden Scenarios (403)" defaultOpen>
        This error occur when doing actions with insufficient permissions such as trying to write with read-Only token.
```js
{
  "errorCode": "FORBIDDEN",
  "errorMessage": "Token does not have required scope",
  "details": [],
  "statusCode": 403
}
```
</Accordion>
    
    <Accordion title="Rate Limiting (429)" defaultOpen>
Rate limiting is applied across all endpoints to ensure proper usage.

```json
{
  "errorCode": "RATE_LIMIT_EXCEEDED",
  "errorMessage": "Too many requests. Please try again later.",
  "details": [],
  "statusCode": 429
}
```
</Accordion>

    <Accordion title="Service Unavailable (503)" defaultOpen>
These errors rarely occur when service is unvailable.

```json
{
  "errorCode": "SERVICE_UNAVAILABLE",
  "errorMessage": "An unexpected error occurred",
  "details": [],
  "statusCode": 503
}
```
</Accordion>
    
</AccordionGroup>




