# KSA ZATCA API v2

The pages for version 2 of the Saudi Arabia (KSA) ZATCA e-invoicing API: account setup, API keys, EGS onboarding, the Unify API and its error messages. API v2 is a legacy version.

> **Legacy API v2**
>
> These pages document API v2, which is no longer developed. They are kept for integrations that still use it. New integrations should use the current API: see [Unify](https://docs.complyance.io/api-reference/unify/) and [Saudi Arabia](https://docs.complyance.io/countries/sa/).

## How the v2 API works

API v2 sends Saudi Arabia e-invoices to ZATCA through one main endpoint, the Unify API. It validates business-to-business (B2B) and business-to-consumer (B2C) documents and generates their QR codes in one request.

Before you can send documents, set up your account and onboard your E-Invoice Generation Solution (EGS):

1. [Sign up](https://docs.complyance.io/legacy/v2/ksa/signup/) to create an account and get a refresh token.
2. [Sign in](https://docs.complyance.io/legacy/v2/ksa/signin/) with the refresh token to get an access token.
3. [Generate an API key](https://docs.complyance.io/legacy/v2/ksa/api-key-generation/) with the access token.
4. [Onboard your EGS](https://docs.complyance.io/legacy/v2/ksa/egs-onboarding/) with the API key.
5. Send documents to the [Unify API](https://docs.complyance.io/legacy/v2/ksa/unify/).

## Pages

- [Sign up](https://docs.complyance.io/legacy/v2/ksa/signup/): Create an account and get a refresh token.
- [Sign in](https://docs.complyance.io/legacy/v2/ksa/signin/): Exchange the refresh token for an access token.
- [API key generation](https://docs.complyance.io/legacy/v2/ksa/api-key-generation/): Generate the API key that the other v2 requests use.
- [EGS onboarding](https://docs.complyance.io/legacy/v2/ksa/egs-onboarding/): Onboard your E-Invoice Generation Solution with ZATCA.
- [Unify API](https://docs.complyance.io/legacy/v2/ksa/unify/): Validate, clear or report documents and get their QR codes.
- [Error messages](https://docs.complyance.io/legacy/v2/ksa/error-messages/): Every error message the Unify API and EGS onboarding return.

Source: https://docs.complyance.io/legacy/v2/ksa/
