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

# Automate coding

> Code entries automatically with rules, AI suggestions and default values.

Most entries can be coded before anyone looks at them. For each dimension,
Slash uses the first of these that applies:

1. A **rule** you've set up, such as "this card always books to Software".
2. A suggestion from the **accounting intelligence** agent.
3. The dimension's **default value**.

## Create a rule

A rule, called a mapping in the API, sets one dimension for every transaction
that involves a given card, merchant, contact or other source. Create one with
[Create or replace an accounting mapping](/api-reference/accounting/mappings/upsert):

```bash theme={null}
curl -X PUT "https://api.slash.com/v2/accounting/mappings" \
  -H "X-API-Key: $SLASH_API_KEY" \
  -H "x-legal-entity: $SLASH_LEGAL_ENTITY_ID" \
  -H "Content-Type: application/json" \
  -d '{
    "source": { "type": "merchant", "id": "merchant_v2_2rj4l7hmrrrcv" },
    "dimensionKey": "account",
    "valueId": "accounting_account_2rj4l7hmrrrcv",
    "applyToExistingEntries": true
  }'
```

New rules apply to entries created from then on. Set `applyToExistingEntries`
to also recode entries that are still `in_review`; sending an existing rule
again with it applies that rule to them.

| Source type | Applies to |
| - | - |
| `card` | Transactions on one card. |
| `card_group` | Transactions on any card in a card group. |
| `merchant` | Card transactions at one merchant (`details.merchant.id` on the transaction). |
| `merchant_category` | Card transactions in one merchant category (`details.merchant.categoryId`). |
| `contact` | Transfers to one contact. |
| `virtual_account` | Transactions on one virtual account. |
| `account` | The bank account side of an account's transactions. Sets `account` only. |
| `accounts_payable` | The accounts payable account bills post to. Takes no `id` and sets `account` only. |

When several rules set the same dimension, the most specific one wins, in
this order:

1. `contact`
2. `merchant`
3. `merchant_category`
4. `card`
5. `card_group`
6. `virtual_account`

Each source sets a dimension at most once, so writing a rule for the same
source and dimension replaces the old one.

On platforms that keep account mappings per subsidiary, such as NetSuite, the
`account` rules of `account` and `accounts_payable` sources belong to the
connection's default subsidiary. Every other rule applies to the whole
connection.

## Review and remove rules

[List accounting mappings](/api-reference/accounting/mappings/list) shows every
rule on the connection, both the ones people wrote (`createdBy: user`) and the
ones the intelligence agent created (`createdBy: ai`). Filter by `sourceType`,
`sourceId` or `dimensionKey`.

[Delete an accounting mapping](/api-reference/accounting/mappings/delete)
removes a rule. Entries it already coded keep their values.

## Accounting intelligence

The accounting intelligence agent codes what no rule covers, based on the
merchant, card and past transactions. Its suggestions are saved as rules, so
you can correct one by writing your own rule for the same source.

Choose which dimensions it codes with
[Update accounting intelligence settings](/api-reference/accounting/intelligence/update):

```json theme={null}
{
  "mode": "selected_fields",
  "enabledDimensionKeys": ["account", "class"]
}
```

| Mode | What the agent codes |
| - | - |
| `all_fields` | Every dimension it supports. |
| `selected_fields` | Only the dimensions in `enabledDimensionKeys`. |
| `disabled` | Nothing. |

The settings you read report `enabledDimensionKeys` as what the agent codes
under the current mode, and you can send that object back unchanged. To pick
dimensions, switch to `selected_fields`.

## Switch dimensions on or off

[Update an accounting dimension](/api-reference/accounting/dimensions/update)
switches a dimension on or off for coding and renames it.

## Set a default value

A default is used when no rule or suggestion applies, for example "everything
is Operations unless a rule says otherwise". Set it with `defaultValueId` on
[Update an accounting dimension](/api-reference/accounting/dimensions/update).

## Choose which values can be used

Charts of accounts often include retired accounts and one-off vendors. Switch
a value off so it can't be used for coding with
[Enable or disable a dimension value](/api-reference/accounting/dimensions/values/update),
or switch up to 100 at once with
[Enable or disable many dimension values](/api-reference/accounting/dimensions/values/bulk).
Entries already coded with a value keep it.

## Pull new records from the platform

Slash refreshes accounts, vendors and other values from the platform on a
schedule. If you just created a record there and need it now, call
[Pull the latest records from the accounting platform](/api-reference/accounting/connections/resync).
The pull runs in the background; list the dimension's values to see when the
new record arrives.


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