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

# Making Requests

> Send API requests to a Blnk Core instance through the Blnk Cloud proxy.

export const CtaCallout = props => {
  const {title, buttonLabel, href, trackingEvent, buttonTarget, rel = "noopener noreferrer", children} = props;
  const handleCtaClick = () => {
    if (typeof window === "undefined" || !trackingEvent) {
      return;
    }
    try {
      window.dispatchEvent(new CustomEvent("blnk:docs-cta", {
        detail: {
          name: trackingEvent,
          href
        }
      }));
    } catch {}
    try {
      window.posthog?.capture?.(trackingEvent, {
        href
      });
    } catch {}
    const gaPayload = {
      cta_href: href
    };
    try {
      window.gtag?.("event", trackingEvent, gaPayload);
    } catch {}
    try {
      window.dataLayer = window.dataLayer || [];
      window.dataLayer.push({
        event: trackingEvent,
        ...gaPayload
      });
    } catch {}
  };
  const isExternal = typeof href === "string" && (/^https?:\/\//i).test(href);
  const target = buttonTarget ?? (isExternal ? "_blank" : undefined);
  const linkRel = isExternal ? rel : undefined;
  return <section className="cta-callout not-prose relative my-8 w-full min-w-0 overflow-hidden rounded-xl border border-zinc-200 p-5 dark:border-white/10">
      <div className="cta-callout-noise" aria-hidden="true" />
      <div className="cta-callout-layout">
        {title ? <div className="cta-callout-title-row">
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 28 28" width="14" height="14" className="cta-callout-icon shrink-0 text-zinc-800 dark:text-zinc-200" aria-hidden="true">
              <g fill="none" fillRule="nonzero">
                <path d="M28 0v28H0V0h28ZM14.691833333333335 27.134333333333334l-0.012833333333333334 0.0023333333333333335 -0.08283333333333333 0.04083333333333334 -0.023333333333333334 0.004666666666666667 -0.016333333333333335 -0.004666666666666667 -0.08283333333333333 -0.04083333333333334c-0.011666666666666667 -0.004666666666666667 -0.022166666666666668 -0.0011666666666666668 -0.028000000000000004 0.005833333333333334l-0.004666666666666667 0.011666666666666667 -0.019833333333333335 0.49933333333333335 0.005833333333333334 0.023333333333333334 0.011666666666666667 0.015166666666666667 0.12133333333333333 0.08633333333333333 0.0175 0.004666666666666667 0.014000000000000002 -0.004666666666666667 0.12133333333333333 -0.08633333333333333 0.014000000000000002 -0.018666666666666668 0.004666666666666667 -0.019833333333333335 -0.019833333333333335 -0.4981666666666667c-0.0023333333333333335 -0.011666666666666667 -0.0105 -0.019833333333333335 -0.019833333333333335 -0.021Zm0.3091666666666667 -0.13183333333333336 -0.015166666666666667 0.0023333333333333335 -0.21583333333333335 0.1085 -0.011666666666666667 0.011666666666666667 -0.0035000000000000005 0.012833333333333334 0.021 0.5016666666666667 0.005833333333333334 0.014000000000000002 0.009333333333333334 0.008166666666666668 0.23450000000000004 0.1085c0.014000000000000002 0.004666666666666667 0.026833333333333334 0 0.03383333333333334 -0.009333333333333334l0.004666666666666667 -0.016333333333333335 -0.03966666666666667 -0.7163333333333334c-0.0035000000000000005 -0.014000000000000002 -0.011666666666666667 -0.023333333333333334 -0.023333333333333334 -0.025666666666666667Zm-0.8341666666666667 0.0023333333333333335a0.026833333333333334 0.026833333333334334 0 0 0 -0.0315 0.007000000000000001l-0.007000000000000001 0.016333333333333335 -0.03966666666666667 0.7163333333333334c0 0.014000000000000002 0.008166666666666668 0.023333333333333334 0.019833333333333335 0.028000000000000004l0.0175 -0.0023333333333333335 0.23450000000000004 -0.1085 0.011666666666666667 -0.009333333333333334 0.004666666666666667 -0.012833333333333334 0.019833333333333335 -0.5016666666666667 -0.0035000000000000005 -0.014000000000000002 -0.011666666666666667 -0.011666666666666667 -0.21466666666666667 -0.10733333333333334Z" strokeWidth="1.1667" />
                <path fill="currentColor" d="M14 2.916666666666667A1.75 1.75 0 0 1 15.750000000000002 4.666666666666667v6.302333333333334L21.207666666666668 7.816666666666667a1.75 1.75 0 0 1 1.75 3.031L17.5 14l5.457666666666667 3.151166666666667a1.75 1.75 0 0 1 -1.75 3.031l-5.457666666666667 -3.1500000000000004V23.333333333333336a1.75 1.75 0 0 1 -3.5 0v-6.302333333333334L6.792333333333334 20.183333333333337a1.75 1.75 0 1 1 -1.75 -3.031L10.5 14 5.042333333333334 10.848833333333333a1.75 1.75 0 0 1 1.75 -3.031l5.457666666666667 3.1500000000000004V4.666666666666667A1.75 1.75 0 0 1 14 2.916666666666667Z" strokeWidth="1.1667" />
              </g>
            </svg>
            <p className="cta-callout-title min-w-0 font-semibold text-zinc-800 dark:text-zinc-200">
              {title}
            </p>
          </div> : null}
        <div className={`cta-callout-body text-sm leading-normal text-zinc-800 dark:text-zinc-200${title ? " cta-callout-body--indented" : ""}`}>
          {children}
        </div>
        <a href={href} target={target} rel={linkRel} onClick={handleCtaClick} data-docs-cta={trackingEvent || undefined} className="cta-callout-button inline-flex items-center justify-center gap-1 rounded-full bg-white px-3 py-1.5 text-sm font-semibold transition hover:bg-zinc-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-white/50 dark:bg-white dark:hover:bg-zinc-200">
          {buttonLabel}
          <span className="cta-callout-button-arrow" aria-hidden="true">
            →
          </span>
        </a>
      </div>
    </section>;
};

The Cloud Proxy lets your app send HTTP requests to a Blnk Core instance through Blnk Cloud, instead of connecting to Core directly.

Blnk Cloud:

* authenticates your request
* uses `instance_id` to determine which Core instance to target
* forwards the request to that instance
* returns the Core response back to your app

### How it works

<img src="https://mintcdn.com/blnk/JB9Zhph4DjE0VsHT/cloud/img/auth/cloud-api.png?fit=max&auto=format&n=JB9Zhph4DjE0VsHT&q=85&s=abe94c638d609e87bfbec7a1f27580ba" alt="How Cloud APIs work" className="rounded-lg" width="1444" height="847" data-path="cloud/img/auth/cloud-api.png" />

* Your app makes requests to Blnk Cloud, using a single base URL.
* You authenticate using an access token. Ensure that your OAuth key includes the `proxy:write` or (or `*`) scope to create or update resources.
* You include an `instance_id` so Cloud knows which Core instance to route the request to.
* Cloud forwards the request to the specified Core instance.

### URL structure

Instead of calling Blnk Core directly:

```bash wrap theme={"system"}
https://YOUR_CORE_INSTANCE_URL/ledgers
```

You call the Cloud Proxy and pass the `instance ID`:

```bash theme={"system"}
proxy_url:
  https://api.cloud.blnkfinance.com/proxy/ledgers?instance_id=YOUR_INSTANCE_ID
headers:
  Authorization: Bearer YOUR_ACCESS_TOKEN
  Content-Type: application/json
```

<Note>
  Read our OAuth docs to [get the access token here](/cloud/auth/oauth#get-an-access-token).
</Note>

***

## Create your first set of records

Here is a minimal flow that matches how Blnk is used in practice:

1. `Create a ledger` (for example, named after your app).
2. `Create two balances` in that ledger.
3. `Create a transaction` from one balance to the other.

<Steps>
  <Step title="Create a ledger">
    Create a ledger named after your app to group your balances:

    <CodeGroup>
      ```bash cURL wrap theme={"system"}
      curl -X POST "https://api.cloud.blnkfinance.com/proxy/ledgers?instance_id=YOUR_INSTANCE_ID" \
        -H "Authorization: Bearer blnk_at_YOUR_ACCESS_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{
          "name": "MyApp Integration Ledger",
          "meta_data": {
            "description": "Ledger for integration test " all test balances live here"
          }
        }'
      ```

      ```json Response wrap theme={"system"}
      {
        "ledger_id": "ldg_073f7ffe-9dfd-42ce-aa50-d1dca1788adc",
        "name": "MyApp Integration Ledger",
        "created_at": "2024-02-20T05:28:03.558281542Z",
        "meta_data": {
          "description": "Ledger for integration test " all test balances and transactions live here"
        }
      }
      ```
    </CodeGroup>

    <Check>
      Save the returned `ledger_id` " you will use it when creating balances.
    </Check>
  </Step>

  <Step title="Create two balances">
    Create two USD balances in that ledger:

    <CodeGroup>
      ```bash cURL theme={"system"}
      curl -X POST "https://api.cloud.blnkfinance.com/proxy/balances?instance_id=YOUR_INSTANCE_ID" \
        -H "Authorization: Bearer blnk_at_YOUR_ACCESS_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{
          "ledger_id": "ldg_073f7ffe-9dfd-42ce-aa50-d1dca1788adc",
          "currency": "USD"
        }'
      ```

      ```json Response theme={"system"}
      {
        "balance": 0,
        "inflight_balance": 0,
        "credit_balance": 0,
        "inflight_credit_balance": 0,
        "debit_balance": 0,
        "inflight_debit_balance": 0,
        "ledger_id": "ldg_073f7ffe-9dfd-42ce-aa50-d1dca1788adc",
        "identity_id": "",
        "balance_id": "bln_5ce86029-3c2e-4e2a-aae2-7fb931ca4c4f",
        "currency": "USD",
        "created_at": "2024-11-26T08:36:36.238244338Z",
        "meta_data": null
      }
      ```
    </CodeGroup>

    Run the same request again to create a second balance (you will get a different `balance_id`).

    <Check>
      Save both **`balance_id`** values " you will use them as `source` and `destination` in Step 3.
    </Check>
  </Step>

  <Step title="Create a transaction between the balances">
    Move money from Balance A (source) to Balance B (destination):

    <CodeGroup>
      ```bash cURL wrap theme={"system"}
      curl -X POST "https://api.cloud.blnkfinance.com/proxy/transactions?instance_id=YOUR_INSTANCE_ID" \
        -H "Authorization: Bearer blnk_at_YOUR_ACCESS_TOKEN" \
        -H "Content-Type: application/json" \
        -d '{
          "amount": 100.50,
          "currency": "USD",
          "precision": 100,
          "reference": "ref_myApp-integration-test-001",
          "source": "bln_5ce86029-3c2e-4e2a-aae2-7fb931ca4c4f",
          "destination": "bln_ANOTHER_BALANCE_ID_FROM_STEP_2",
          "description": "Integration test: transfer from Balance A to Balance B",
          "allow_overdraft": true
        }'
      ```

      ```json Response theme={"system"}
      {
        "amount": 100.50,
        "rate": 0,
        "precision": 100,
        "precise_amount": 10050,
        "transaction_id": "txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c",
        "parent_transaction": "",
        "source": "bln_5ce86029-3c2e-4e2a-aae2-7fb931ca4c4f",
        "destination": "bln_ANOTHER_BALANCE_ID_FROM_STEP_2",
        "reference": "ref_myApp-integration-test-001",
        "currency": "USD",
        "description": "Integration test: transfer from Balance A to Balance B",
        "status": "QUEUED",
        "hash": "hash_...",
        "allow_overdraft": true,
        "inflight": false,
        "created_at": "2024-11-26T08:40:00.000000000Z",
        "scheduled_for": "0001-01-01T00:00:00Z",
        "inflight_expiry_date": "0001-01-01T00:00:00Z"
      }
      ```
    </CodeGroup>

    <Check>
      If the transaction returns `status=QUEUED`, Core applies it asynchronously. To verify the final state, fetch the transaction (and updated balances) via the [Data API](/cloud/proxy/data-api).
    </Check>
  </Step>
</Steps>

***

## Working with metadata

Ledgers, balances, transactions, and identities all support **metadata** (`meta_data`) " custom key"value data you attach for enrichment, tagging, or integration, e.g. `customer_id`, `channel`, `region`, `approval_status`.

<Steps>
  <Step title="Choose a top-level key for your app">
    Use a single top-level key (for example, your app name) under `meta_data` so your enrichment does not clash with user-defined or other apps' metadata:

    ```json theme={"system"}
    {
      "meta_data": {
        "myApp": {
          "channel": "web",
          "customer_id": "cust_abc123"
        }
      }
    }
    ```
  </Step>

  <Step title="Call the metadata update endpoint">
    Call the following URL to enrich metadata:

    ```bash wrap theme={"system"}
    POST https://api.cloud.blnkfinance.com/proxy/<resource_id>/metadata?instance_id=<YOUR_INSTANCE_ID>
    ```

    * `<resource_id>`: The ID of the resource you want to update (for example, a `ledger_id`, `balance_id`, `transaction_id`, or `identity_id`).

    Each call updates the resource's `meta_data`:

    * If a key already exists, the value you send overwrites it.
    * If a key does not exist, it is added.
  </Step>

  <Step title="Enrich a resource">
    Use the tabs below to see example metadata updates for each resource type:

    <Tabs>
      <Tab title="Ledger">
        Update metadata on a ledger, e.g. `project_owner`, `description`, etc.

        ```bash cURL wrap theme={"system"}
        curl -X POST "https://api.cloud.blnkfinance.com/proxy/ldg_073f7ffe-9dfd-42ce-aa50-d1dca1788adc/metadata?instance_id=YOUR_INSTANCE_ID" \
          -H "Authorization: Bearer blnk_at_YOUR_ACCESS_TOKEN" \
          -H "Content-Type: application/json" \
          -d '{
            "meta_data": {
              "myApp": {
                "project_owner": "Acme LLC",
                "description": "All test balances and transactions for MyApp"
              }
            }
          }'
        ```
      </Tab>

      <Tab title="Balances">
        Update metadata on a balance, e.g. `account_type`, `customer_segment`, `region`, `approval_status`, etc.

        ```bash cURL wrap theme={"system"}
        curl -X POST "https://api.cloud.blnkfinance.com/proxy/bln_5ce86029-3c2e-4e2a-aae2-7fb931ca4c4f/metadata?instance_id=YOUR_INSTANCE_ID" \
          -H "Authorization: Bearer blnk_at_YOUR_ACCESS_TOKEN" \
          -H "Content-Type: application/json" \
          -d '{
            "meta_data": {
              "myApp": {
                "account_type": "savings",
                "segment": "retail"
              }
            }
          }'
        ```
      </Tab>

      <Tab title="Transactions">
        Update metadata on a single transaction, e.g. `channel`, `recipient`, `risk_score`, `destination_country`, etc.

        ```bash cURL wrap theme={"system"}
        curl -X POST "https://api.cloud.blnkfinance.com/proxy/txn_c4e70eb8-e4d6-4e04-a2e2-92a43b969e0c/metadata?instance_id=YOUR_INSTANCE_ID" \
          -H "Authorization: Bearer blnk_at_YOUR_ACCESS_TOKEN" \
          -H "Content-Type: application/json" \
          -d '{
            "meta_data": {
              "myApp": {
                "channel": "web",
                "customer_id": "cust_abc123",
                "approval_status": "approved"
              }
            }
          }'
        ```
      </Tab>

      <Tab title="Identities">
        Update metadata on an identity, such as segment and KYC status.

        ```bash cURL wrap theme={"system"}
        curl -X POST "https://api.cloud.blnkfinance.com/proxy/idt_3b63c8da-af29-4cc3-ad38-df17d87456e6/metadata?instance_id=YOUR_INSTANCE_ID" \
          -H "Authorization: Bearer blnk_at_YOUR_ACCESS_TOKEN" \
          -H "Content-Type: application/json" \
          -d '{
            "meta_data": {
              "myApp": {
                "segment": "premium",
                "kyc_status": "verified",
                "source": "onboarding_flow"
              }
            }
          }'
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Read the updated metadata response">
    For all metadata update calls:

    * **Status:** `200 OK`
    * **Body:** The resource's updated `meta_data` object. Example:

    ```json Success theme={"system"}
    {
      "meta_data": {
        "myApp": {
          "channel": "web",
          "customer_id": "cust_abc123",
          "approval_status": "approved"
        }
      }
    }
    ```
  </Step>
</Steps>

***

## See all available endpoints

For the complete list of Proxy API routes, see the [Proxy API reference](/cloud/reference/proxy-api).

To see request and response shapes for individual operations, use the [Blnk Core API reference](https://docs.blnkfinance.com/reference).

Use the Core docs to determine the request path, HTTP method, and body. Then send the same request through Blnk Cloud via the Cloud Proxy base URL, `Authorization` header and the `instance_id` query parameter, as shown earlier on this page.

***

<CtaCallout title="Need help building your app?" href="https://blnkfinance.com/contact/us?utm_source=blnk_docs&utm_medium=documentation&utm_campaign=apps-help" buttonLabel="Get Pro Support" trackingEvent="clicked_pro_support">
  We help you build custom apps for your use case or get help building your own from scratch.
</CtaCallout>
