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

# Function Nodes

Function nodes perform operations on data, make API requests, or interact with external systems. They are the core building blocks for implementing integration logic in flows.

Many function nodes use [Function Types](/docs/references/functions) to implement their logic. The configuration and behavior is defined by the corresponding function type.

<br />

## Data Record Operations

These nodes operate on data records in external applications. Most of them map directly to function types.

| Node Type                | Description                             | Function Type                                                                              |
| :----------------------- | :-------------------------------------- | :----------------------------------------------------------------------------------------- |
| `list-data-records`      | List all records from a data collection | [List Data Records](/docs/references/functions/function-types/list-data-records)           |
| `find-data-record-by-id` | Find a single record by its ID          | [Find Data Record By ID](/docs/references/functions/function-types/find-data-record-by-id) |
| `search-data-records`    | Search for records using a query string | [Search Data Record](/docs/references/functions/function-types/search-data-record)         |
| `lookup-data-record`     | Look up a record by field values        | [Match Data Record](/docs/references/functions/function-types/match-data-record)           |
| `create-data-record`     | Create a new data record                | [Create Data Record](/docs/references/functions/function-types/create-data-record)         |
| `update-data-record`     | Update an existing data record          | [Update Data Record](/docs/references/functions/function-types/update-data-record)         |
| `delete-data-record`     | Delete a data record                    | [Delete Data Record](/docs/references/functions/function-types/delete-data-record)         |

<br />

## Find or Create Data Record

**Type:** `find-or-create-data-record`

Attempts to find a record by specified criteria. If no record is found, creates a new one. This is useful for upserting data.

```yaml theme={null}
findOrCreate:
  type: find-or-create-data-record
  name: Find or Create Contact
  config:
    dataSource:
      collectionKey: contacts
    lookupFields:
      email:
        $var: input.trigger.email
    createData:
      firstName:
        $var: input.trigger.firstName
      lastName:
        $var: input.trigger.lastName
      email:
        $var: input.trigger.email
    fieldMapping:
      key: contact-mapping
```

**Configuration options:**

* **`dataSource`** – Specifies which [Data Source](/reference/workspace-elements/data-sources) to use
* **`lookupFields`** – Fields to match when searching for existing records
* **`createData`** – Data to use when creating a new record
* **`fieldMapping`** – [Field Mapping](/reference/workspace-elements/field-mappings) for the operation

**Output:**

Returns the found or newly created data record:

```javascript theme={null}
{
  id: 'contact-456',
  name: 'Jane Smith',
  fields: {
    firstName: 'Jane',
    lastName: 'Smith',
    email: 'jane@example.com'
  },
  created: false  // true if record was created, false if found
}
```

<br />

## Create Data Link

**Type:** `create-data-link`

Creates a [Data Link](/reference/workspace-elements/data-links) between an object in your app and an object in an external app.

```yaml theme={null}
createLink:
  type: create-data-link
  name: Link Contact
  config:
    dataLinkTable: contact-links
    internalId:
      $var: input.trigger.internalContactId
    externalId:
      $var: input.createRecord.id
    direction: both
```

**Configuration options:**

* **`dataLinkTable`** – The Data Link table to use (must be created first)
* **`internalId`** – ID of the object in your app
* **`externalId`** – ID of the object in the external app
* **`direction`** – Link direction: `export` (internal → external), `import` (external → internal), or `both`

If a link already exists, it will be updated.

**Output:**

Returns the created or updated data link:

```javascript theme={null}
{
  id: 'link-789',
  internalId: 'internal-contact-123',
  externalId: 'external-contact-456',
  direction: 'both'
}
```

<br />

## Find Data Link

**Type:** `find-data-link`

Finds a [Data Link](/reference/workspace-elements/data-links) to get the corresponding object ID on the opposite side.

```yaml theme={null}
findLink:
  type: find-data-link
  name: Find Linked Contact
  config:
    dataLinkTable: contact-links
    internalId:
      $var: input.trigger.internalContactId
```

**Configuration options:**

* **`dataLinkTable`** – The Data Link table to search
* **`internalId`** – ID to look up (can be internal or external depending on direction)

**Output:**

Returns the ID of the matching record on the opposite side, or null if no link is found:

```javascript theme={null}
{
  externalId: 'external-contact-456'
}
// or null if not found
```

<br />

## Delete Data Link

**Type:** `delete-data-link`

Deletes an existing [Data Link](/reference/workspace-elements/data-links).

```yaml theme={null}
deleteLink:
  type: delete-data-link
  name: Unlink Contact
  config:
    dataLinkTable: contact-links
    internalId:
      $var: input.trigger.internalContactId
```

**Configuration options:**

* **`dataLinkTable`** – The Data Link table containing the link
* **`internalId`** – ID of the linked object

**Output:**

Returns confirmation of deletion:

```javascript theme={null}
{
  success: true,
  deletedLinkId: 'link-789'
}
```

<br />

## HTTP Request Operations

These nodes make HTTP requests to APIs and external services.

| Node Type                     | Description                                      | Function Type                                                                                        |
| :---------------------------- | :----------------------------------------------- | :--------------------------------------------------------------------------------------------------- |
| `api-request-to-external-app` | Make authenticated API requests to external apps | [API Request to External App](/docs/references/functions/function-types/api-request-to-external-app) |
| `api-request-to-your-app`     | Make API requests to your internal API           | [API Request to Your App](/docs/references/functions/function-types/api-request-to-your-app)         |
| `custom-http-request`         | Make arbitrary HTTP requests to any endpoint     | [HTTP Request](/docs/references/functions/function-types/http-request)                               |

<br />

## Code Execution

These nodes execute code and run predefined actions.

| Node Type        | Description                                  | Function Type                                                      |
| :--------------- | :------------------------------------------- | :----------------------------------------------------------------- |
| `run-javascript` | Execute custom JavaScript or TypeScript code | [JavaScript](/docs/references/functions/function-types/javascript) |
| `run-action`     | Execute a predefined action                  | [Run Action](/docs/references/functions/function-types/run-action) |

<br />

## Integration Specific Operation

**Type:** `integration-specific-operation`

Executes operations that are specific to a particular integration. These are pre-built operations provided by connectors.

```yaml theme={null}
specialOp:
  type: integration-specific-operation
  name: Send Email
  config:
    operationKey: send-email
    parameters:
      to:
        $var: input.findContact.fields.email
      subject: Welcome!
      body:
        $var: input.transform.emailBody
```

**Configuration options:**

* **`operationKey`** – Key of the integration-specific operation
* **`parameters`** – Parameters required by the operation

The available operations and their parameters depend on the specific connector being used. Refer to connector documentation for details.

**Output:**

Returns the result of the operation. Structure varies by operation:

```javascript theme={null}
{
  success: true,
  messageId: 'msg-123',
  // ... other operation-specific fields
}
```
