> For the complete documentation index, see [llms.txt](https://docs.thewalletcrew.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.thewalletcrew.io/developers-guides/scripting/modules/secutix.md). Agents can also search and read this documentation through its [MCP server](https://docs.thewalletcrew.io/~gitbook/mcp).

# twc/secutix

Call the Secutix API from a script with fetch from the twc/secutix module - relative URLs, default content type, retries and timeouts.

A tenant that uses the Secutix connector sometimes needs data that the connector does not map by default, such as an extra order detail. The `twc/secutix` module offers a `fetch` function for that: it works like the [global `fetch`](https://docs.thewalletcrew.io/developers-guides/scripting/globals/fetch.md), but it is wired to the Secutix connection of the tenant. The path of the request is relative to the connection, and the authentication, the rate limiting and the retry rules of the Secutix connector are applied by the platform, so the script contains no credential.

The module is meant for Secutix calls only. Every other system is called with the global `fetch`.

<details>

<summary><strong>Real-world examples</strong></summary>

* A contact mapper script reads an additional Secutix resource of the customer and copies one field to the account.
* A movement mapper script checks the status of an order with a second Secutix call before choosing the pass type.

</details>

## Import and signature

```js
import { fetch } from "twc/secutix";

const res = await fetch("/path/of/the/service", { Method: "POST", Body: { id: movementId } });
```

| Function              | Parameters                                                      | Returns                                                                 |
| --------------------- | --------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `fetch(url, options)` | `url`: string; `options`: the same object as the global `fetch` | A promise of `{ StatusCode, ResponseText }`, as for the global `fetch`. |

The imported `fetch` replaces the global one inside the file that imports it. A file that also needs the global function for another system imports under another name:

```js
import { fetch as secutixFetch } from "twc/secutix";
```

The old name `neo/secutix` still works; see [Obsolete neostore names](https://docs.thewalletcrew.io/developers-guides/scripting/modules/obsolete-neo-names.md). The prefix `neostore` is the platform's former name and is kept in technical identifiers.

## What differs from the global fetch

All options (`Method`, `Headers`, `Body`, `ThrowOnError`, `Cache`, `Throttle`) and the result shape are the ones documented on [fetch](https://docs.thewalletcrew.io/developers-guides/scripting/globals/fetch.md), including the default of throwing on a non-2xx status. The differences are the following.

| Aspect                 | Behavior of `twc/secutix`                                                                                                                                                       |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| URL                    | A relative URL, such as `/services/example`, is resolved against the Secutix connection configured for the tenant.                                                              |
| Authentication         | Added by the platform to every request. The `Authentication` option is not needed.                                                                                              |
| Default `Content-Type` | `application/json` when the `Headers` do not contain a `Content-Type`. No charset is added.                                                                                     |
| Retries                | The call is retried only when Secutix answers `429` or `509`, at most two times, with a randomised delay of about ten seconds. Other errors are not retried.                    |
| Rate limiting          | Calls are paced by the platform per Secutix host, with the limit set under **API rate limiting** in the Secutix connector settings (**Enable rate limiting** is on by default). |
| Timeout                | An attempt is abandoned after 30 seconds.                                                                                                                                       |

Since `5xx` answers and network errors are not retried, a script that must be resilient to a brief Secutix outage handles the error itself. Because `429` and `509` are retried, a `POST` to Secutix must still be safe to repeat.

## Example

The pass data provider below enriches the account with the answer of one Secutix call, and leaves the account unchanged if Secutix does not answer properly, returning `false` so that the platform knows nothing was found. The path `/services/customer-segment` is a placeholder for a real Secutix service path.

```js
import { fetch as secutixFetch } from "twc/secutix";

export default function (context) {
  context.register("runtime.scriptable.passDataProvider.secutixSegment", {
    Fill: async (entity) => {
      const res = await secutixFetch("/services/customer-segment", {
        Method: "POST",
        Body: { email: entity.email },
        ThrowOnError: false,
        Cache: { CacheKey: "segment:" + entity.email, DurationInMs: 10 * 60 * 1000 }
      });

      if (res.StatusCode !== 200 || !res.ResponseText) {
        console.warn("Segment lookup answered " + res.StatusCode);
        return false;
      }
      entity["secutix.segment"] = JSON.parse(res.ResponseText).segment;
      return true;
    }
  });
}
```

The endpoint is described on [Pass data provider](https://docs.thewalletcrew.io/developers-guides/scripting/endpoints/pass-data-provider.md). The scripts of the Secutix extension endpoints can use the same module; their keys are on [Secutix scripts](https://docs.thewalletcrew.io/developers-guides/scripting/extensions/secutix.md).

## Checking the result

The mapped value is visible on the pass data after the flow that runs the script. A `404` usually means that the relative path is wrong or that the Secutix service is not enabled for the connection; a `401` or `403` is a credentials or rights matter of the Secutix connection, to be checked with the Secutix connector setup rather than in the script.

## FAQ

<details>

<summary><strong>Why does a failing call take longer than 30 seconds to fail?</strong></summary>

A call answered with `429` or `509` is retried twice, each attempt having its own 30-second timeout and a delay of about ten seconds separating the attempts, so the total stays around two minutes in the worst case. Caching the answer and using `ThrowOnError: false` limits the impact on the request that runs the script.

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.thewalletcrew.io/developers-guides/scripting/modules/secutix.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
