> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cortex-labs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect an API with your own key

> Use Kato to draft an Ingest script bundle, then test it against a small dataset before collecting production data. An Admin stores the key; Kato needs only its secret name.

Use Kato to draft an Ingest script bundle, then test it against a small dataset before collecting production data. An Admin stores the key; Kato needs only its secret name.

A **secret** holds the credential, an **Ingest bundle** defines collection, and a **job** pins a published bundle version and sends its output to one dataset.

## Before you begin

You need Vantage access, Forge authoring rights, permission to ingest into a test dataset and a deployment with confined script execution. An Admin must be available to set the secret.

Gather the API's documentation, HTTPS endpoint, authentication method and a small permitted sample response. Use a key with the minimum access the job needs.

## 1. Save the key as a secret

An Admin opens **Console → Secrets**, chooses a name such as `source-api-token`, and enters the credential through the secure form. Check that its source reads **Tenant key**.

Give Kato the exact secret name. Keep the value out of chat, code, job parameters and logs. Stored values cannot be read back, including by the Admin.

Secrets have no workspace scope. Use a distinct name for each credential and inspect its consumers before changing it. See [Manage secrets and destinations](https://docs.cortex-labs.ai/administration/configuration-and-usage/secrets-and-destinations.md).

## 2. Ask Kato to draft the bundle

Adapt this request to the API's documented authentication and pagination:

> Draft an Ingest script bundle in TypeScript for \[endpoint and HTTP method]. Read the credential from the secret named \[secret name] using the API's documented authentication method. Use \[API documentation] and this permitted sample response: \[sample]. Collect a small bounded page, preserve stable source IDs and checkpoint the continuation position. Declare only the required host and port. Show me the code, descriptor, parameters and output declaration before creating anything. Do not create a job or start collection.

Ask Kato to identify missing information rather than guessing API behaviour. For deciding parameters and mapping output, use [Bring API data into the world model](https://docs.cortex-labs.ai/vantage/bring-in-data/map-api-data.md).

## 3. Inspect the proposal

| Check | What to confirm |
| - | - |
| Credential | The code reads the secret by name; its value is absent. |
| Network | Only the required API hosts and ports are declared. |
| Parameters | Non-sensitive values match the API contract. |
| Records | The output declaration matches the sample and uses stable natural keys. |
| Continuation | The checkpoint and end-of-results behaviour are explicit. |
| Limits | Time, memory and output limits suit a small first run. |
| Bundle kind | **Ingest**, which is fixed at creation. |

A null continuation cursor can mean different things to different APIs. Agree how the job stops or starts its next collection cycle before publishing.

## 4. Publish and create the test job

Ask Kato to create and publish the reviewed bundle, then create a job targeting your test dataset and pinned to that version. Keep all triggers disabled.

Inspect any approval card before approving its named operation. Open the job yourself and check its destination, version, parameters and secret status.

A draft bundle cannot be tested. A missing or revoked required secret must be resolved before running.

## 5. Run an isolated test

Ask for a test of this job and version. Inspect emitted records, validation errors and the proposed checkpoint. Production records and the production checkpoint should remain unchanged.

Test an empty response, malformed input and an unavailable endpoint as well as a successful response. Ask Kato to revise failures, publish a new version, pin it and test again.

## 6. Start one bounded run

After the same job/version passes its test, start one small production run. Inspect the destination records and saved checkpoint. Repeated source IDs should identify the same item; changed content creates a new item version.

Add a [schedule or webhook](https://docs.cortex-labs.ai/vantage/build-and-automate/schedule-or-webhook.md) only after checking the result.

## Change or recover the connection

| Change or symptom | Next step |
| - | - |
| Bundle changes | Publish, pin the new version and test again. |
| Key rotation | An Admin rotates the secret. New admissions use the new version; an in-flight run keeps its recorded version. |
| Secret revoked | Resolve the usable credential before retrying. Revocation prevents further delivery of that version. |
| Missing prerequisites | Inspect the named missing secrets in Console. |
| Request blocked | Check the declared host and port, revise and retest. |
| API returns 401 or 403 | Have the Admin check expiry and API access. |
| Kato stops partway | Retain created resource IDs and continue from them. |
| Parsing fails | Inspect retained input and recovery options before collecting again. |

Pause collection and wait for running jobs to finish before resetting a production checkpoint. For recovery, see [Run ingestion and inspect processing](https://docs.cortex-labs.ai/vantage/bring-in-data/run-ingestion.md).

For the TypeScript and descriptor reference, see [Build and test a custom ingestion job](https://docs.cortex-labs.ai/vantage/bring-in-data/custom-ingestion-job.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.