# Response Error Example

> See how to return structured errors in API Maker using g.res.errors, including statusCode and error format.

Source: https://docs.apimaker.dev/v1/examples/res/errors/errors.html

### Set errors in the response.

```ts
g.res.errors = [{ code: 400, message: "Error message here." }];
```

Response
```json
{
    "success": false,
    "statusCode": 400,
    "errors": [
        {
            "code": 400,
            "message": "Error message here."
        }
    ],
    "warnings": []
}
```

## Related

- [The global object g](https://docs.apimaker.dev/v1/docs/pre-defined-terms/global-object-g.html) · [Custom APIs](https://docs.apimaker.dev/v1/docs/apis-all/custom-apis/user-created-custom-api.html)
