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

# Set Agreement Policy

> Switch loan agreements off, to optional or to required on a market

Sets the market's loan agreement policy. A setting made here always wins: it replaces a policy that came from a standing policy, and no standing policy overwrites it later. Fields you leave out keep their current value.

Switching to `OPTIONAL` or `REQUIRED` needs the Scale plan on the bank's instance. Switching to `OFF` is always allowed. Agreements already issued stay as they are; `OFF` only stops the gate and the binding.

## Who can set it

The bank: an API key of an instance with a verified wallet that holds `DEFAULT_ADMIN_ROLE` on the market.

## Path Parameters

**marketId** `string` *required*

The market's record ID on your instance.

## Body Parameters

**mode** `string`

`OFF`, `OPTIONAL` or `REQUIRED`.

**validityDays** `number`

1 to 365. How long an issued `LOAN` agreement's offer stays open. Default 30.

**autoIssue** `boolean`

Issue a borrower's request at once when its figures are inside the market rules. Default `false`.

**autoIssueMaxAmount** `string`

With `autoIssue` on, the largest borrow amount issued at once, as a decimal of the borrow asset such as `"50000"`. A larger request stays `REQUESTED` for the bank. `null` removes the ceiling. Default `null`. Left out, the current value stays.

**frameworkValidityDays** `number`

7 to 1830. How long a `FRAMEWORK` agreement runs when the bank creates one without `validUntil`. `null` means no default, so `validUntil` stays required. Default `null`.

**requestAccess** `string`

Who may request agreements on this market. `ANY`, the default, lets every instance with access to the market request one for its borrowers. `BANK_ONLY` closes requests: only the bank creates agreements, and a request from another instance answers `403 AGREEMENT_REQUESTS_CLOSED`.

**signerAddress** `string`

The admin wallet to record as the setter. Defaults to your first verified admin wallet.

## Response Fields

The policy as [Get Agreement Policy](https://docs.trusset.org/endpoints/lending/get-agreement-policy.md#response-fields) returns it.

```json 200 Saved theme={null}
{
  "success": true,
  "data": {
    "policy": {
      "mode": "OPTIONAL",
      "validityDays": 14,
      "autoIssue": true,
      "autoIssueMaxAmount": "50000",
      "frameworkValidityDays": 365,
      "requestAccess": "ANY",
      "source": "MANUAL",
      "standingPolicyId": null,
      "setByWallet": "0x5ad87a0621175206b72d10e4b8577b192e7f40ab",
      "setByThisInstance": true,
      "updatedAt": "2026-11-21T15:41:10.402Z",
      "enforcement": "BACKEND_CHECK",
      "notice": null,
      "viewer": {
        "isBank": true,
        "canConfigure": true,
        "planAllows": true
      }
    },
    "marketId": "cmwfk2h7x0003jw9w4q8b2n1c"
  },
  "error": null
}
```

## Error Codes

| Code | HTTP | Cause |
| - | - | - |
| `DOCUMENT_CONTENT_REFUSED` | `400` | The body carries file content. Keep the file with you and send only the salted commitment |
| `PLAIN_HASH_REFUSED` | `400` | The body carries the plain hash of a file (`contentHash`, `sha256` and similar). Send the salted commitment instead |
| `PERSONAL_DATA_REFUSED` | `400` | The body carries a personal data field such as `name` or `email`. Use wallet addresses and `externalReference` only |
| `VALIDATION_ERROR` | `400` | A field is missing, has the wrong type, or is not part of this route |
| `INVALID_AGREEMENT_POLICY` | `400` | `mode`, `validityDays`, `autoIssue`, `autoIssueMaxAmount`, `frameworkValidityDays` or `requestAccess` is out of range |
| `AGREEMENT_FEATURE_REQUIRED` | `402` | Your plan does not include loan agreements. Upgrade to Scale, or keep the policy `OFF` |
| `AGREEMENT_BANK_ONLY` | `403` | No verified wallet of your instance holds `DEFAULT_ADMIN_ROLE` on the market |
| `SIGNER_NOT_MARKET_ADMIN` | `403` | `signerAddress` is not one of your verified admin wallets |
| `MARKET_NOT_FOUND` | `404` | No market with this ID on your instance |
| `CHAIN_UNAVAILABLE`, `SERVICE_UNAVAILABLE` | `503` | The market or your instance's wallets could not be read just now. Nothing was decided. Retry shortly |


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