Skip to main content
The CustomApiResourceClient allows you to make HTTP requests to external APIs that you have configured as resources in Major.

Usage

import { myApiClient } from "./clients";

const result = await myApiClient.invoke("POST", "/v1/orders", "create-order", {
  body: { type: "json", value: { productId: "p_123", quantity: 1 } },
  headers: { "X-Custom-Auth": "secret" },
  query: { currency: "USD" },
});

if (result.ok) {
  console.log("Status:", result.result.status);
  if (result.result.body.kind === "json") {
    console.log("Response:", result.result.body.value);
  }
}

Inputs

The invoke method accepts the following arguments:
method
string
required
The HTTP method to use: "GET", "POST", "PUT", "PATCH", or "DELETE".
path
string
required
The URL path to append to the resource’s base URL.
invocationKey
string
required
A unique identifier for this operation.
options
object
Optional configuration object.

Outputs

On success (ok: true), the result object contains:
kind
"api"
Discriminator for the response type.
status
number
The HTTP status code returned by the API.
body
ResponseBody
The response body.