# IApiReferenceExporter Methods

- Package: [Aspire.TypeSystem](/reference/api/csharp/aspire.typesystem.md)
- Type: [IApiReferenceExporter](/reference/api/csharp/aspire.typesystem/iapireferenceexporter.md)
- Kind: `Methods`
- Members: `1`

Optional companion to [ICodeGenerator](/reference/api/csharp/aspire.typesystem/icodegenerator.md) for languages that can describe their generated surface as a machine-readable API reference.

<a id="exportapi"></a>
<a id="exportapi-atscontext-apireferenceexportoptions-cancellationtoken"></a>

## ExportApi(AtsContext, ApiReferenceExportOptions, CancellationToken)

- Name: `ExportApi(AtsContext, ApiReferenceExportOptions, CancellationToken)`
- Modifiers: `abstract`
- Returns: `JsonElement`

Exports the API reference for the surface the generator would produce from the same context.

```csharp
public interface IApiReferenceExporter
{
    public abstract JsonElement ExportApi(
        AtsContext context,
        ApiReferenceExportOptions options,
        CancellationToken cancellationToken)
    {
        // ...
    }
}
```

## Parameters

- `context` ([AtsContext](/reference/api/csharp/aspire.typesystem/atscontext.md))
  The ATS context containing capabilities, types, and enums.
- `options` ([ApiReferenceExportOptions](/reference/api/csharp/aspire.typesystem/apireferenceexportoptions.md))
  The package identity and ownership scope for the export. Assembly ownership matching follows the case-insensitive contract documented by [ApiReferenceExportOptions.ExportingAssemblyNames](/reference/api/csharp/aspire.typesystem/apireferenceexportoptions/properties.md#exportingassemblynames).
- `cancellationToken` (`CancellationToken`)
  A token to cancel the export between projected items.

## Returns

`JsonElement` -- A language-defined JSON document describing the generated API. The returned element must be detached from any owning `Json.JsonDocument`, for example by calling `JsonElement.Clone`.

## Exceptions

- `OperationCanceledException` -- Thrown when `cancellationToken` requests cancellation.

## Examples

```csharp
using var document = JsonDocument.Parse(json);
return document.RootElement.Clone();
```
