# Sourcegraph API

Starting in [Sourcegraph 7.0](https://sourcegraph.com/changelog/releases/7.0), a new versioned external API is being introduced for custom integrations (see the [announcement](https://sourcegraph.com/changelog/sourcegraph-api)). The currently available API surface can be seen in `/api-reference` (e.g. `https://sourcegraph.example.com/api-reference`). From this page, integrators can view the available operations and download the OpenAPI schema. We are committed to supporting integrations built on top of these new APIs with backwards compatibility and migration assistance for breaking changes.

<Callout type="note">
	The new Sourcegraph API is a work in progress, and capabilities are
	gradually being ported over. If you have an integration you'd like to build
	that is not currently served by the new Sourcegraph API, please reach out at
	support@sourcegraph.com.
</Callout>

For specific types of integrations, Sourcegraph also offers the following APIs:

- [Sourcegraph streaming search API](/api/stream-api/), for consuming search results as a stream of events
- [Sourcegraph MCP server](/api/mcp/), for connecting AI agents and applications to Sourcegraph's code search capabilities
- [Sourcegraph Analytics API](/analytics/api/), for accessing your Sourcegraph Analytics data
- [Webhooks](/admin/webhooks/), for receiving event notifications from Sourcegraph

For diagnostics use cases, the [Sourcegraph GraphQL debug API](/api/graphql/) is also available without any compatibility guarauntees.

<Callout type="warning">
	<p>The Sourcegraph GraphQL API has historically been an internal interface
	without formal compatibility guarantees. For external integrations,
	[Sourcegraph 7.0](https://sourcegraph.com/changelog/releases/7.0) introduces a new, supported API at `/api-reference`.
	The GraphQL API remains available, but we recommend migrating to the
	new API for a stable integration experience.</p>

    <p>If you have a
    use case that is not currently served by the new Sourcegraph API, please
    reach out at support@sourcegraph.com.</p>

</Callout>

## Tracking integration usage

If you'd like our help breaking down and analyzing API usage across different integrations, include some or all of the following headers in your requests:

- `X-Requested-With: <your-app-name>/<version>` — a stable identifier for the calling integration
- `X-Sourcegraph-API-Client-Name: <caller-name>` — the caller's name, for example, `my-integration`
- `X-Sourcegraph-API-Client-Feature: <feature-or-tool>` — the feature or tool making the request, so that different call sites from the same integration are distinguishable
- `X-Sourcegraph-API-Client-Version: <version>` — the integration's build or version

When an API request triggers a [telemetry](/admin/telemetry/) event, Sourcegraph includes the values of these headers in the event.
