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

# Partners in STA

> Confine a partner's Lerian STA credential to the STA credentials you choose, tell it how to name them on each request, and read the refusals it receives.

A [partner](https://docs.lerian.studio/en/platform/access-manager/features/partners/overview) can call [Lerian STA](https://docs.lerian.studio/en/rails/sta/what-is-lerian-sta.md) with its own credential. In Lerian STA, you confine that credential to some STA credentials: the institution and operator logins Lerian STA uses to exchange files with BACEN. This page shows how to choose that scope, what it reaches, and what the partner receives when it goes outside it.

Every Lerian STA partner needs a scope: at least one STA credential.

## Step by step

***

**1. Choose what the partner works with**

The **API field** is the `field` of a scope entry; the Console shows the name in the first column.

| Restriction | API field | What the partner reaches | What it is refused |
| - | - | - | - |
| **STA credential** | `credentialId` | Its own STA credentials: reading, changing, testing, rotating and deleting them, and their access log. Sending a transfer and creating an inbound source with one of them. | Other STA credentials, the list of credentials, every transfer and inbound source read or changed by its own ID, the lists of transfers and inbound sources, the audit exports and the transfer history, and the runtime configuration. |

Each value is the ID that Lerian STA returns when you create the credential.

The scope catalog lists the Lerian STA restriction. Read it with [Retrieve a product's scope catalog](https://docs.lerian.studio/en/reference/platform/access-manager/retrieve-a-product-s-scope-catalog.md) for `br-sta`.

Some rules apply to every scope:

* A request that does not name an STA credential is refused. For example, a partner cannot list the credentials, the transfers or the inbound sources of your installation.
* A query that lists several credentials is refused when any one of them is outside the scope.

**2. Give the partner its permissions and scope**

Create the partner, or change it, in the [Console](https://docs.lerian.studio/en/platform/access-manager/features/partners/console.md) or with the [Identity API](https://docs.lerian.studio/en/platform/access-manager/features/partners/api.md). The product slug is `br-sta`.

* Add at least one scope entry for Lerian STA. Without one, Access Manager refuses the partner with `400` and `IDE-1060`.
* Check the resources and actions. The most you can give is what the editor role of `br-sta` holds in your tenant.

Access Manager checks each permission you give against the scope. A permission that acts on the whole installation is never given to a partner, and is refused with `400` and `IDE-1056` (a write) or `IDE-1052` (a read no request of the partner can reach). The Console marks the line **Outside the scope**. In Lerian STA, these are creating STA credentials, reading, retrying and cancelling transfers, marking an inbound transfer urgent, reading, changing, deleting and polling inbound sources, the audit exports and the runtime configuration.

The permissions a partner can receive are `credentials` with `credentials:read`, `credentials:update`, `credentials:delete`, `credentials:test` and `credentials:rotate`; `transfers` with `transfers:create`; `inbound-source-configs` with `inbound-source-configs:create`; and `audit` with `audit:read`.

**3. Create its Lerian STA application**

Create the partner's application with the product `br-sta`. See [Create the partner's applications](https://docs.lerian.studio/en/platform/access-manager/features/partners/api.md#create-the-partners-applications) in the API guide, or [in the Console](https://docs.lerian.studio/en/platform/access-manager/features/partners/console.md#create-the-partners-applications). Send the client ID and the client secret to the partner through a secure channel.

**4. Tell the partner how to name its credentials**

On the credential routes the STA credential is already in the path. On the others, the partner names it in the body or the query that Lerian STA already has.

| Routes | Writes | Reads and routes by ID |
| - | - | - |
| One credential: `/v1/credentials/{credentialId}`, `/test`, `/rotate`, `/current-password` | `PATCH`, `DELETE`, `POST /test`, `POST /rotate`, `PUT /current-password`: path `credentialId` | Path `credentialId` |
| Transfers: `/v1/transfers` | To send: body `credentialId` | None: a transfer is read by its own ID and is refused |
| Inbound sources: `/v1/inbound-source-configs` | To create: body `credentialId` | None: a source is read by its own ID and is refused |
| Credential access log: `/v1/audit/credential-access-logs` | None | To read: query `credentialId` |

> [!WARNING]
>
> A partner can send a transfer with its credential but cannot read the transfer back: Lerian STA reads a transfer, an inbound source and an audit export by their own ID, which names no credential. Follow those records with your own credential.

**5. Confirm that it works**

This check assumes the partner has the `credentials` resource with the `credentials:read` action on Lerian STA, and a scope with one STA credential. Use the partner's credential. Read the STA credential in its scope. The answer is `200`:

```bash theme={null}
STA_BASE_URL="https://sta.<your-domain>"                   # your Lerian STA base URL
STA_BEARER_TOKEN="paste-the-partner-access-token-here"
CREDENTIAL_ID="paste-an-sta-credential-id-in-the-scope-here"

curl -s -o /dev/null -w '%{http_code}\n' \
  -H "Authorization: Bearer ${STA_BEARER_TOKEN}" \
  "${STA_BASE_URL}/v1/credentials/${CREDENTIAL_ID}"
```

Send the same request with an STA credential outside the scope. The answer is `403`. To see the code, drop `-o /dev/null`: the response body carries `STA-0004`.

## If something fails

***

| Code | Status | What it means | What to do |
| - | - | - | - |
| `STA-0004` | 403 | The request is outside the partner's permissions or outside its scope, it does not name an STA credential, or the caller's IP is outside the partner's list. | Check that the request names its STA credential in the field of that route, with a value in the partner's scope. Check also the partner's permissions and IP list. |
| `STA-0003` | 401 | The partner is suspended, or the request is outside the partner's validity window. | Reactivate the partner, or change its validity window. |

The answer does not say whether the permissions or the scope refused the request. This is on purpose: a partner cannot use a refusal to learn which credentials exist outside its scope.

For every other code, see the [Lerian STA error list](https://docs.lerian.studio/en/reference/rails/sta/sta-error-list.md). For the refusals when you create or change a partner, see [Error codes](https://docs.lerian.studio/en/platform/access-manager/features/partners/api.md#error-codes) in the API guide.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.