# Create a GraphQL API

A GraphQL API gets its operations from its schema: every query and every mutation becomes an operation. The **New API** wizard asks where the schema comes from before it asks for code.

## Before you begin

- A model provider connected to your workspace. See [Connect your model provider](https://docs.faustine.ai/get-started/connect-your-ai-provider/).
- One of these: the URL of the running GraphQL endpoint and a credential that is allowed to introspect it, a schema file, or the repository.

## Choose the schema source

| Source | What Faustine reads | Choose it when |
| --- | --- | --- |
| **Fetch from connection** | The result of an introspection query sent to your live endpoint | The endpoint is reachable and introspection is on. This is the most reliable source. |
| **Upload SDL or introspection JSON** | A `.graphql` or `.gql` file, or the JSON result of an introspection query, up to 5 MB | Introspection is off in the environment Faustine can reach. |
| **Analyze the repository** | SDL files, a committed generated schema, or code-first definitions | The schema exists only in code. |

When a repository is also connected, the analysis checks it too. Introspection and SDL take precedence over what the code says.

## Create the API

1. In the portal, go to [**APIs**](https://auth.faustine.ai/go?to=%2Fintegrations%2Fapis) and select **New API**.
2. In **API type**, select **GraphQL**.
3. In **Language & framework**, select your framework, or **Other / not listed**.
4. In **Details**, enter a **Name** and a **Namespace**, then select **Continue**. The namespace cannot be changed later.
5. In **Schema source**, select one of the three sources:
   - **Fetch from connection**: under **Authentication**, choose how the API signs in. Then enter the connection's **Name**, **Base URL** and credential values. The base URL is the endpoint every query is sent to. This becomes the API's first connection.
   - **Upload SDL or introspection JSON**: select **Choose file**.
   - **Analyze the repository**: you pick the repository in the next step.
6. Select **Continue**.
7. In **Repository (optional)**, connect the repository and select **Continue**, or select **Skip**. If the repository is the schema source, the step is named **Connect your code** and is required.
8. If you connected a repository, choose **Automatic** or **Manual** in **Keep the API up to date**.
9. In **Review & analyze**, select **Create & start analysis**.

The analysis page opens. When the run finishes, select **Open the API page**. The **Operations** tab lists one operation for each query and mutation.

> **Note:** A credential that cannot introspect the whole schema sees part of it, and the API then has fewer operations than the service. Use a credential with full introspection rights for **Fetch from connection**.

## What the repository adds

With the code connected, the analysis also reads the resolvers. It uses them to decide which mutations are destructive, and the API can update on every push. Without a repository, the contract comes from the schema alone.

## Change the source later

**Re-analyze** in the **Actions** menu asks **Where the contract comes from** each time: the code or uploaded schema, or **The live service (introspection)** through one of the API's connections. To replace an uploaded schema file, use **Settings** > **Code & contract** > **Schema file**. The new file takes effect on the next analysis.

## Next steps

- [GraphQL](https://docs.faustine.ai/technologies/graphql/): how Faustine calls a GraphQL service.
- [Operations](https://docs.faustine.ai/apis/operations/): review the queries and mutations the analysis found.
- [Connections](https://docs.faustine.ai/apis/connections/): add the other environments of the service.
