Articles in this section

Configure an API request using API builder

The API request defines what callers can send to your API: the HTTP method, the relative URI, parameters, headers, and the request body. Configure it first, because every later step in the API works with the data that the request accepts. You also create the mock request here, preview the parsed data, and review the transformation that passes the request data to the next step.

For sample requests, see Get all shops, Get a chocolate, Create a new chocolate, and Composite API. To see where the request fits on the canvas, see API builder overview.

The Define API request panel with the General and Configure API request sections.

Name the request

  1. On the canvas, select the API request step to open Define API request.
  2. Enter values for the following settings.
Setting Required What to enter
Name your API request Yes A name that identifies the request in other parts of the application.
Description No A summary of what the request does, so that other users understand it without reading every setting.
Trace key template No A handlebars template that sets the trace key for each request. The trace key appears in request history.

Leave Trace key template blank to use the default trace key. For more on trace keys, see View API request and execution logs in API builder and Set a custom trace key to uniquely identify a record.

Choose the method and relative URI

  1. In HTTP method, choose the method for your API. An API supports one HTTP method.
  2. In Relative URI, enter the path of your API endpoint.
Method Use it to
GET Retrieve data.
POST Create a resource.
PUT Update a resource.
PATCH Partially update an existing resource.
DELETE Delete a resource.

The relative URI starts with a forward slash (/) and can't be empty. It is relative to https://api.integrator.io/apis/<version>, where the version is the one in your API's settings. To change the version, see Configure advanced API settings.

The endpoint URL is publicly accessible, and only callers with a valid API token can invoke it. Two enabled APIs in the same account can't have the same endpoint URL. For how callers authenticate, see Invoke an API and API limits.

Path parameters

To add a path parameter, enter a colon (:) followed by the parameter name in the relative URI. You can add more than one. For example, /shops/:shopId/chocolates/:chocolateId has the path parameters shopId and chocolateId.

Path parameters lists each parameter that you add to the relative URI. Each parameter has a Description. To rename or remove a path parameter, edit the relative URI.

Query parameters

Use query parameters to let callers filter the data that your API returns, such as filtering chocolates by type or cocoa percentage.

  1. In Query parameters, enter a name in the blank row.
  2. Choose the data type: string, number, or boolean.
  3. Enter a Description.
  4. To require the parameter, select Additional settings on its row, and then select Required.

A query parameter is optional unless you mark it Required. API builder doesn't report an error when a caller omits an optional query parameter or sends it with the wrong data type. When validation is on, the data type isn't checked for any query parameter. For what validation checks, see What validation checks.

To remove a query parameter, delete its row.

Add HTTP headers

Add custom headers that your API expects.

  1. In HTTP headers, enter a header name in the blank row.
  2. Enter a Description.

Header names support letters, numbers, hyphens, and underscores. API builder doesn't validate headers. Remove a header by deleting its row.

Token authentication is built in, so you don't add an Authorization header to invoke an API with a token. To use other authentication types, such as JWT or OAuth 2.0, see The API Management console - Features and concepts.

Define the request body

HTTP request body appears for methods that send a body, such as POST. It doesn't appear for GET. Define the schema of the JSON that callers send. Field data types are string, number, boolean, object, and array, and the schema can include nested objects and arrays. If you need background on JSON, see JSON.

The request payload supports one record at a time.

Generate schema from sample JSON

  1. In Generate schema from sample JSON, select Choose file.
  2. Select a .json file.

API builder builds field names, nesting, and types from the file. It doesn't set lengths, ranges, enum values, or patterns, and it doesn't keep the file. If the body already has fields, API builder asks you to confirm before it replaces them.

In your file In the schema
Whole numbers Number
A list that's empty or has mixed types No item type
A null value A field whose type you set

API builder rejects a file that isn't valid JSON, isn't a .json file, is empty, is larger than 10 MB, or doesn't have an object at the top level. Your schema doesn't change when it rejects a file.

Add schema manually

  1. Select Add schema manually.
  2. Enter the field Name, choose its type, and enter a Description.
  3. Select + to add another field.

To remove a field, delete its row.

Switch between Visual and JSON

The request body editor has two views. Visual shows your schema as rows of fields. JSON shows the same schema as JSON. The editor opens in the view that you last saved.

  1. To switch to JSON, select JSON.
  2. To switch back, select Visual, and then select Continue in the Switch view dialog.

Switching to Visual can remove validation rules that Visual can't show. Select Cancel to stay in JSON, and review your configuration after you switch.

Set rules on a field

To require a field or limit its values, select Additional settings on the field's row. The settings depend on the field type. For the full list, see Set rules on a field.

Edit the mock API request

The mock API request is sample data that API builder generates from your request configuration. Edit it to preview different requests and to test how your API handles them.

  1. Select Mock API request.
  2. Edit the JSON. The keys are pathParams, queryParams, headers, and body.
  3. To discard your changes, select Reset to sample data.

The mock request must be valid JSON. Adding a body field updates the mock request body. If your parameters, headers, or body fall out of sync with the mock request, a warning appears on the API request. When you save, API builder prompts you to update the mock request and the transformation to match.

Don't enter personal information in the mock request. API builder keeps mock request data.

Preview the request

  1. Select Preview.
  2. Select Send.

Parsed output shows the JSON that the next steps in your API receive. Select HTTP request to see the request as a cURL command. Select Copy copy-icon.png to copy the command and use it in Postman or another tool.

When validation is on, Preview checks the mock request and lists any errors in Parsed output. See Preview and test runs.

The Preview panel showing the HTTP request as a cURL command.

Check requests before the API runs

The platform returns an error to the caller before your API runs when a request is malformed, missing a required body, or sent to an unknown path. For the list of errors callers can receive, see Error handling in API builder. To also check requests against your body and query parameter rules, see Validate API requests and responses in API builder.

View debug logs

Select View debug logs to see errors for your API request before you run a test. For how to read the logs, see View API request and execution logs in API builder.

Transform the request data

A transformation reshapes the request data before it reaches the next step. The path parameters, query parameters, headers, and body arrive in the source record under the keys pathParams, queryParams, headers, and body.

Review the automatic rules

When you define parameters or headers, API builder pre-populates transformation rules for them. It adds rules only for the types you define. For example, an API with query and path parameters but no headers gets queryParams and pathParams rules. API builder adds rules only when the request has no saved transformation, and it never changes a saved one.

  1. Select Transformation transformation-icon.png on the connection after the API request.
  2. Review the rules.
  3. Select Save.

The Configure indicator stays on the transformation until you open it and save.

Add transformation rules manually

  1. In Define transformation, choose Rules 1.0, Rules 2.0, or JavaScript.
  2. In Output, enter the name of the field to create.
  3. In Input, select the request value to copy into it.

Add a rule for every value you want to keep, even a value you don't change. Rules run in the order they appear. Drag a rule to change its order. For more on transformations, see Transformations.