Skip to main content

Node api

This node allows interaction with various APIs, which is useful for integration with external services.


Node API Settings

IMG2

1. Name

Field for specifying the name of the node.
The name is displayed in the workspace and helps easily identify the node.
If left empty, the node will be called API.

Example:

  • Node name: Create Payment Session

2. Method

Here, the API method to be used for sending the request is selected. Available methods:

  • "Create Payment Session":
    Creates a new payment session.

  • "Update Payment Session":
    Updates an existing payment session.

  • "Get Payment Session by ID":
    Retrieves information about the payment session by the unique session identifier.

  • "Get Payment Session by Order ID":
    Retrieves information about the payment session using the order identifier.

Example:

  • Method: Create Payment Session

3. Data

This field uses the Mustache template to form the request data in JSON format.
You can use data from the msg message to substitute values in the template.

Template example (for the "Create Payment Session" method):

 {
"orderId": {{orderId}},
"type": "session"
}

In this example, the value of orderId will be substituted from the msg message.

Template example (for the "Update Payment Session" method):

 {
"id": {{paymentSessionId}},
"paymentUrl": "{{{payload.links.1.href}}}"
}

When using Mustache templates, you can pass complex data and parameters needed for interacting with the API.


Request Examples

Example 1: Creating a Payment Session

Node settings:

  • Method: Create Payment Session
  • Data:
    {
    "orderId": {{orderId}},
    "type": "session"
    }

Message:

{
"orderId": 123
}

Result:
The node will send a request to create a payment session with the data from the message. As a result, information about the new payment session will be received.


Example 2: Updating a Payment Session

Node settings:

  • Method: Update Payment Session
  • Data:
    {
    "id": {{paymentSessionId}},
    "paymentUrl": "{{{payload.links.1.href}}}"
    }

Message:

{
"paymentSessionId": 123,
"payload": {
"id": "8YP51523N05861826",
....
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8YP51523N05861826",
"rel": "self",
"method": "GET"
},
{
"href": "https://www.sandbox.paypal.com/checkoutnow?token=8YP51523N05861826",
"rel": "payer-action",
"method": "GET"
}
]
}
}

Result:
The node will send a request to update the status of the payment session using the provided values payment_session_id and status.


Example 3: Getting a Payment Session by ID

Node settings:

  • Method: Get Payment Session by ID
  • Data:
    {
    "id": "{{paymentSessionId}}"
    }

Message:

{
"paymentSessionId": 123
}

Result:
The node will send a request to retrieve information about the payment session by the unique session identifier.


Example 4: Getting a Payment Session by Order ID

Node settings:

  • Method: Get Payment Session by Order ID
  • Data:
    {
    "orderId": "{{payload.id}}"
    }

Message:

{
"payload": {
"id": 1
}
}

Result:
The node will send a request to retrieve information about the payment session associated with the specified order identifier.