# Importing an API Source

To create an API store, you need to first connect your APIs to MagicAPI.

When a user calls MagicAPI,  then MagicAPI will call your APIs using the defined API source and the config.

The API config needs to be defined as an OpenAPI spec. If you don't have an OpenAPI spec yet, you can create one using ChatGPT.  You can follow this tutorial with example ChatGPT prompts  [create-openapi-spec-using-chatgpt](https://docs.magicapi.com/fundamentals/create-openapi-spec-using-chatgpt "mention")

1. Click on API Sources on the left side menu. Then click on the "Import Api Source" button.

<figure><img src="https://1246015681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIIfH52JYp16prB6DFxbJ%2Fuploads%2Fbt1r0wBUIY98j5z7AVsP%2Fimage.png?alt=media&#x26;token=28bc9735-46fb-4720-bf6d-48011610e9f1" alt=""><figcaption></figcaption></figure>

Click Next to proceed.

2. Import the OpenAPI YAML or JSON file. You should be able to see the paths imported from the YAML file.

<figure><img src="https://1246015681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIIfH52JYp16prB6DFxbJ%2Fuploads%2F49BdGgAwXoO0lUj59mRy%2Fimage.png?alt=media&#x26;token=689e4e8f-4d5b-4377-ba1e-d6c1d5c34771" alt=""><figcaption></figcaption></figure>

Click Next to proceed.

3. Enter a name and version for your API Source. All these details are Internal only and will never be exposed to your users.

<figure><img src="https://1246015681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIIfH52JYp16prB6DFxbJ%2Fuploads%2Fgf7maah20IbG8ZUIjZ2n%2Fimage.png?alt=media&#x26;token=ffa17000-f65c-4ba7-9eae-55080f8d2a0e" alt=""><figcaption></figcaption></figure>

Click Next to proceed.

4. Set Custom Header for your API.

You can set custom headers. These are headers that will be set by MagicAPI for every request before being sent to your API. This needs to be a valid JSON key-value map.

Example:

```json
{"source" : "MAGICAPI" }
```

This can be used to set and kind of headers including Authentication or API keys that are needed by your API Source endpoint.

<figure><img src="https://1246015681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIIfH52JYp16prB6DFxbJ%2Fuploads%2FxZoewDpnTUVPmRbGPoFB%2Fimage.png?alt=media&#x26;token=c7cc1bee-bb64-4391-a17d-06c4ca695277" alt=""><figcaption></figcaption></figure>

Click Next to proceed.

5. Set the Base Path URL.

This is the URL that MagicAPI's backend will call. This is never exposed to end users.

<figure><img src="https://1246015681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIIfH52JYp16prB6DFxbJ%2Fuploads%2FLSYtaw8dSZGjLuqa4TNR%2Fimage.png?alt=media&#x26;token=dbde2e3a-614a-4f4a-84c2-f38a950d00ac" alt=""><figcaption></figcaption></figure>

Click Next to proceed.

6. Set Authentication

You can set Authentication headers using this window. You can use either this or use custom headers to pass Authentication to your API. This is used by MagicAPI to authenticate when calling your API. This is not exposed to users.

You can choose No Auth as well.

<figure><img src="https://1246015681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIIfH52JYp16prB6DFxbJ%2Fuploads%2FpQWKKSkumP2F7sOXXBVv%2Fimage.png?alt=media&#x26;token=22b05a36-afba-4b48-85dd-705eea9aff51" alt=""><figcaption></figcaption></figure>

Click Next to proceed.

7. Summary.

Finally, check the Summary of your API Source and click on Submit.

<figure><img src="https://1246015681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIIfH52JYp16prB6DFxbJ%2Fuploads%2FLBGa0QBginBJei0OZVKg%2Fimage.png?alt=media&#x26;token=b5625f61-73d2-433f-890b-74617b437aee" alt=""><figcaption></figcaption></figure>

You should see the newly created API Source on the API Sources Page.\
\
Next step if to create "Products" with Pricing Plans attached. Click next to learn more.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.magicapi.com/overview/importing-an-api-source.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
