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

# APIs

> Import APIs from Postman, cURL, or Swagger into Rocket and attach them to UI elements automatically.

export const LlmsDirective = () => <blockquote className="llms-directive">
    For the complete documentation index, see <a href="/llms.txt">llms.txt</a>.
    For a lightweight markdown version of this page, append .md to the URL.
  </blockquote>;

<LlmsDirective />

Import API definitions from Postman, cURL, Swagger, or OpenAPI specs. Rocket generates all the connection code, error handling, and data mapping. You pick the endpoint and the UI element.

<Note>
  API imports are only available on the web browser. They are not supported in the Rocket mobile app.
</Note>

## What you can connect

<CardGroup cols={2}>
  <Card title="Payment processors" icon="credit-card">
    Stripe, PayPal, or any payment API with checkout flows, subscriptions, and invoicing.
  </Card>

  <Card title="Databases and backends" icon="database">
    Supabase, Firebase, your own REST API, or any backend that exposes endpoints.
  </Card>

  <Card title="Third-party services" icon="cloud">
    Weather APIs, maps, social media, shipping, SMS, email, and any service with a REST API.
  </Card>

  <Card title="Your own APIs" icon="server">
    Internal microservices, staging environments, or any custom backend you have built.
  </Card>
</CardGroup>

<Divider />

## Before you start

You need one of the following:

* A Postman API key and workspace
* A working cURL command
* A Postman collection export file (`postman.json`)
* A Swagger or OpenAPI spec (JSON or YAML)

You also need any environment variables your API definitions reference, such as `base_url` or `accessToken`.

<Card icon="key" href="/build/editor/env-variables" horizontal arrow="true">
  Learn how to manage secret keys as environment variables.
</Card>

<Divider />

## Open the APIs panel

Click the **`...`** button in the preview toolbar and select **APIs**.

<Frame caption="Opening the APIs panel from the toolbar">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/open-apis-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=0cd90829214dc6997b3b758c9eafe744" alt="Toolbar dropdown with APIs option highlighted." className="theme-image light-image" width="2880" height="1624" data-path="images/build-docs/editor/apis/web-browser/open-apis-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/open-apis-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=e66d4d489f76d384b3003a5275210482" alt="Toolbar dropdown with APIs option highlighted." className="theme-image dark-image" width="2880" height="1624" data-path="images/build-docs/editor/apis/web-browser/open-apis-dark.webp" />
</Frame>

<Divider />

## Import APIs

In the APIs panel, open the **Select an API** dropdown and click **Add APIs** to open the import dialog. Pick one of four import methods.

<AccordionGroup>
  <Accordion title="Postman key (workspace import)" defaultOpen="true">
    Use this when your APIs already live in a Postman workspace.

    **Get your Postman API key:**

    <Card icon="link" horizontal href="https://learning.postman.com/docs/developer/postman-api/authentication/#generate-a-postman-api-key" arrow="true">
      <b>Visit Postman's documentation to learn how to generate your API key.</b>
    </Card>

    1. Click your avatar in the Postman header, then click **Settings**.
    2. Go to **API keys** and click **Generate API Key**.
    3. Enter a name and copy the key.

    <Info>
      Your Postman API key provides access to any Postman data you have permissions for. Keep it private and rotate it if you believe it has been exposed.
    </Info>

    **Import into Rocket:**

    1. In **Add APIs**, select the **Postman** tab.
    2. Paste your **Postman Key**.
    3. Select the **workspace**.
    4. Click **Submit**, then select the collections or folders you want to add.
    5. Click **Add APIs**.

    <Frame caption="Postman key and workspace selection">
      <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/postman-tab-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=5e0e1e73547594313c22270109895dcf" alt="Postman import tab showing key input and workspace selection." className="theme-image light-image" width="1594" height="1112" data-path="images/build-docs/editor/apis/web-browser/postman-tab-light.webp" />

      <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/postman-tab-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=b86ef9b7abf6eaa1a7d599f2dce91f4f" alt="Postman import tab showing key input and workspace selection." className="theme-image dark-image" width="1592" height="1114" data-path="images/build-docs/editor/apis/web-browser/postman-tab-dark.webp" />
    </Frame>
  </Accordion>

  <Accordion title="cURL (single request import)">
    Use this when you have a working request you can paste.

    1. In **Add APIs**, select the **cURL** tab.
    2. Paste the full cURL command.
    3. Click **Add API**.

    <Frame caption="cURL import tab">
      <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/curl-tab-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=cd628a1d8b04b9d03d3bed6eb7a53463" alt="cURL import tab with command input field." className="theme-image light-image" width="1590" height="1110" data-path="images/build-docs/editor/apis/web-browser/curl-tab-light.webp" />

      <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/curl-tab-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=68239b1ea428273134d5a330916e2f19" alt="cURL import tab with command input field." className="theme-image dark-image" width="1584" height="1108" data-path="images/build-docs/editor/apis/web-browser/curl-tab-dark.webp" />
    </Frame>

    Make sure the cURL includes the correct URL, headers, and auth format. If it uses environment variables, map them to your project's variable format after import.
  </Accordion>

  <Accordion title="Upload JSON (Postman export file)">
    Use this when you have a Postman export file.

    1. In **Add APIs**, select **Upload JSON**.
    2. Drag and drop or upload your `postman.json`.
    3. Click **Submit**.

    <Frame caption="Upload JSON tab">
      <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/upload-json-tab-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=5c57437eaf51a43a2872ac806d0dfefc" alt="Upload JSON tab with file upload area." className="theme-image light-image" width="1588" height="1110" data-path="images/build-docs/editor/apis/web-browser/upload-json-tab-light.webp" />

      <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/upload-json-tab-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=843432cf364dda9ff1fc4a9540aa79f9" alt="Upload JSON tab with file upload area." className="theme-image dark-image" width="1596" height="1110" data-path="images/build-docs/editor/apis/web-browser/upload-json-tab-dark.webp" />
    </Frame>
  </Accordion>

  <Accordion title="Swagger (OpenAPI import)">
    Use this when your backend provides an OpenAPI spec.

    1. In **Add APIs**, select **Swagger**.
    2. Drag and drop or upload your Swagger JSON or YAML file.
    3. Click **Submit**.

    <Frame caption="Swagger upload tab">
      <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/swagger-tab-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=9df4866c01e8ec5aacf693dd4913f4ac" alt="Swagger import tab with file upload area." className="theme-image light-image" width="1596" height="1116" data-path="images/build-docs/editor/apis/web-browser/swagger-tab-light.webp" />

      <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/swagger-tab-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=a60f9026800d46a86c03f8f80b5d850a" alt="Swagger import tab with file upload area." className="theme-image dark-image" width="1596" height="1114" data-path="images/build-docs/editor/apis/web-browser/swagger-tab-dark.webp" />
    </Frame>

    If your spec defines multiple servers, confirm the base URL matches your environment.
  </Accordion>
</AccordionGroup>

<Divider />

## Integrate an API into a UI element

This connects an endpoint to a screen element so Rocket generates code tied to a real component.

### Select a route and API

In the APIs panel, choose the **route** (the screen or page path, for example `/dashboard` or `/settings`) where the API should run, and select the API from the **Select an API** dropdown. Then click **Integrate API**.

<Frame caption="Route picker, API dropdown, and Integrate API button">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/integrate-api-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=4c842230a2d999133c2932d8170628d3" alt="Route selection and API dropdown with Integrate API button." className="theme-image light-image" width="1816" height="180" data-path="images/build-docs/editor/apis/web-browser/integrate-api-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/integrate-api-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=02576c160d1eb947775ab3d5bf02e3da" alt="Route selection and API dropdown with Integrate API button." className="theme-image dark-image" width="1816" height="180" data-path="images/build-docs/editor/apis/web-browser/integrate-api-dark.webp" />
</Frame>

### Click a UI element

After clicking **Integrate API**, element selection activates. A tag bar appears at the top of the preview showing the available elements. Click the UI element where you want to attach the API.

<Frame caption="Element selection bar in API integration mode">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/select-element-bar-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=c8e9f443ec796ca9b9813207b74d895d" alt="Element tag bar showing div and span options for API attachment." className="theme-image light-image" width="1818" height="456" data-path="images/build-docs/editor/apis/web-browser/select-element-bar-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/select-element-bar-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=401fef2f7914fca9e5815cd5f83d3ae7" alt="Element tag bar showing div and span options for API attachment." className="theme-image dark-image" width="1818" height="456" data-path="images/build-docs/editor/apis/web-browser/select-element-bar-dark.webp" />
</Frame>

<Frame caption="Clicking an element in the preview to attach the API">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/select-element-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=0b009995f7dd4d07f700155d61de30f1" alt="Full screen view of element selection with API dropdown and preview visible." className="theme-image light-image" width="2880" height="1624" data-path="images/build-docs/editor/apis/web-browser/select-element-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/select-element-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=69e7fe3c5d7e9b35bad26fb73f44def0" alt="Full screen view of element selection with API dropdown and preview visible." className="theme-image dark-image" width="2880" height="1624" data-path="images/build-docs/editor/apis/web-browser/select-element-dark.webp" />
</Frame>

<Note>
  Attach to a stable container element that is always present on the screen. Avoid conditional elements that may not exist on initial render.
</Note>

### Configure the trigger

After selecting the element, the **When to call this API?** dialog opens. Fill in:

* **When should this API run** (the trigger, e.g. "On page load", "On click of Submit button")
* **Pre API call Instructions** (validation, auth checks, token refresh)
* **Post API call Instructions** (store response, handle errors, navigate on failure)

<Frame caption="When to call this API configuration dialog">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/when-to-call-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=eea2ebbfcbf573f558e02705e88c1782" alt="When to call this API dialog with trigger, pre-call, and post-call instruction fields." className="theme-image light-image" width="960" height="726" data-path="images/build-docs/editor/apis/web-browser/when-to-call-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/when-to-call-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=c66510744b71d5980984ec33efa76781" alt="When to call this API dialog with trigger, pre-call, and post-call instruction fields." className="theme-image dark-image" width="960" height="726" data-path="images/build-docs/editor/apis/web-browser/when-to-call-dark.webp" />
</Frame>

Click **Submit** and Rocket generates the integration code.

**Pre-call tips:**

* Validate required variables exist (base URLs, IDs, query params)
* Check auth state (token exists, not expired)
* Refresh token here if possible

**Post-call tips:**

* Store response data into a named state variable your UI can bind to
* Cache successful responses to improve performance
* Handle error states with clear user feedback
* Navigate when needed (e.g. redirect to login on 401)

<Note>
  Clear pre and post-call instructions help Rocket generate robust error handling code.
</Note>

<Divider />

## Edit an API response

To update a mock or expected response for an API, open the **Add/Edit API Response** dialog for that endpoint and paste the updated JSON, then click **Update**.

<Frame caption="Add/Edit API Response dialog">
  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/edit-response-light.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=54af00571e4ce2fca840e2d1a272901e" alt="Add/Edit API Response dialog showing JSON response content." className="theme-image light-image" width="1598" height="1122" data-path="images/build-docs/editor/apis/web-browser/edit-response-light.webp" />

  <img src="https://mintcdn.com/dhiwisepvtltd-5e04e6a4/8nOfBUphIU8HGZ4Z/images/build-docs/editor/apis/web-browser/edit-response-dark.webp?fit=max&auto=format&n=8nOfBUphIU8HGZ4Z&q=85&s=97dddbcef247d05dc807a96e975aac49" alt="Add/Edit API Response dialog showing JSON response content." className="theme-image dark-image" width="1598" height="1122" data-path="images/build-docs/editor/apis/web-browser/edit-response-dark.webp" />
</Frame>

<Divider />

## Troubleshooting

<AccordionGroup>
  <Accordion title="The API picker is empty">
    Import did not complete, or you imported into a different project. Reopen **Add APIs** and verify your source: check that your Postman API key is valid, that your Postman workspace contains collections, and that you are importing into the correct project.
  </Accordion>

  <Accordion title="Integration asks for attributes you did not expect">
    The imported definition includes placeholders. Map them to known state variables or environment variables. Set any placeholder like `accessToken` to reference your stored token value and confirm the request uses the correct auth scheme (e.g. `Authorization: Bearer <token>`).
  </Accordion>

  <Accordion title="Calls run but the UI does not update">
    Response data is likely not stored to the variable your UI is bound to. Update the Post API call instructions to store the response, then bind your UI list or widget to that variable.
  </Accordion>

  <Accordion title="You get 401 Unauthorized">
    Token is missing, expired, or not attached correctly. Fix in Pre API call instructions and ensure auth header formatting is correct (e.g. `Bearer <token>`).
  </Accordion>
</AccordionGroup>

<Divider />

## What's next?

<CardGroup cols={2}>
  <Card title="Chat interface" icon="messages" href="/build/editor/chat">
    Build and iterate on your app through natural conversation.
  </Card>

  <Card title="Inject custom code" icon="file-code" href="/build/editor/custom-code">
    Add scripts, embeds, and UI components from external sources.
  </Card>

  <Card title="Integrations" icon="puzzle-piece" href="/build/connectors/overview">
    Some services have dedicated integrations that are simpler than raw API imports.
  </Card>

  <Card title="Code tab" icon="code" href="/build/editor/code">
    Browse and edit your project's source files directly.
  </Card>
</CardGroup>
