> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.ntropy.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.ntropy.com/_mcp/server.

# Set a custom set of categories

POST https://api.ntropy.com/v3/categories/{id}
Content-Type: application/json

Sets a custom set of categories. Transactions that don't match a category will be categorized `not enough information` regardless of whether it is present in the set.

Reference: https://docs.ntropy.com/documentation/api/categories/custom-categories-post-v-3-categories-id-post

## Authentication

- `X-Api-Key` header (required) — API Key authentication via header

## Request

### Path parameters

- `id` (string, required)

### Body (application/json)

This endpoint expects a CustomCategorySet.

- `incoming` (map from string to string, required)
- `outgoing` (map from string to string, required)

## Response

### 200

Custom categories successfully set.

- `incoming` (map from string to string, required)
- `outgoing` (map from string to string, required)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)
- `input` (any, optional)
- `ctx` (ValidationErrorCtx, optional)

### ValidationErrorLocItems

### ValidationErrorCtx

## Examples

**Request**

```json
{
  "incoming": {
    "investment income": "Income earned from investments.",
    "other income": "Income not covered by another available category.",
    "salary": "Income paid by an employer as wages or salary."
  },
  "outgoing": {
    "entertainment": "Payment for recreation or entertainment.",
    "groceries": "Purchase of food and household staples.",
    "rent": "Payment for ongoing use of a residence or property.",
    "utilities": "Payment for household utility services."
  }
}
```

**Response**

```json
{
  "incoming": {
    "investment income": "Income earned from investments.",
    "other income": "Income not covered by another available category.",
    "salary": "Income paid by an employer as wages or salary."
  },
  "outgoing": {
    "entertainment": "Payment for recreation or entertainment.",
    "groceries": "Purchase of food and household staples.",
    "rent": "Payment for ongoing use of a residence or property.",
    "utilities": "Payment for household utility services."
  }
}
```

**SDK Code**

```python Python SDK
from ntropy_sdk import SDK

sdk = SDK("cd1H...Wmhl")
categories = sdk.categories.set(
    "my_category_id",
    {
        "incoming": {
            "salary": "Income paid by an employer as wages or salary.",
            "investment income": "Income earned from investments.",
            "other income": "Income not covered by another available category.",
        },
        "outgoing": {
            "rent": "Payment for ongoing use of a residence or property.",
            "utilities": "Payment for household utility services.",
            "groceries": "Purchase of food and household staples.",
            "entertainment": "Payment for recreation or entertainment.",
        },
    },
)
```

```javascript
const url = 'https://api.ntropy.com/v3/categories/id';
const options = {
  method: 'POST',
  headers: {'X-Api-Key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"incoming":{"investment income":"Income earned from investments.","other income":"Income not covered by another available category.","salary":"Income paid by an employer as wages or salary."},"outgoing":{"entertainment":"Payment for recreation or entertainment.","groceries":"Purchase of food and household staples.","rent":"Payment for ongoing use of a residence or property.","utilities":"Payment for household utility services."}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.ntropy.com/v3/categories/id"

	payload := strings.NewReader("{\n  \"incoming\": {\n    \"investment income\": \"Income earned from investments.\",\n    \"other income\": \"Income not covered by another available category.\",\n    \"salary\": \"Income paid by an employer as wages or salary.\"\n  },\n  \"outgoing\": {\n    \"entertainment\": \"Payment for recreation or entertainment.\",\n    \"groceries\": \"Purchase of food and household staples.\",\n    \"rent\": \"Payment for ongoing use of a residence or property.\",\n    \"utilities\": \"Payment for household utility services.\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Api-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.ntropy.com/v3/categories/id")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"incoming\": {\n    \"investment income\": \"Income earned from investments.\",\n    \"other income\": \"Income not covered by another available category.\",\n    \"salary\": \"Income paid by an employer as wages or salary.\"\n  },\n  \"outgoing\": {\n    \"entertainment\": \"Payment for recreation or entertainment.\",\n    \"groceries\": \"Purchase of food and household staples.\",\n    \"rent\": \"Payment for ongoing use of a residence or property.\",\n    \"utilities\": \"Payment for household utility services.\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.ntropy.com/v3/categories/id")
  .header("X-Api-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"incoming\": {\n    \"investment income\": \"Income earned from investments.\",\n    \"other income\": \"Income not covered by another available category.\",\n    \"salary\": \"Income paid by an employer as wages or salary.\"\n  },\n  \"outgoing\": {\n    \"entertainment\": \"Payment for recreation or entertainment.\",\n    \"groceries\": \"Purchase of food and household staples.\",\n    \"rent\": \"Payment for ongoing use of a residence or property.\",\n    \"utilities\": \"Payment for household utility services.\"\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.ntropy.com/v3/categories/id', [
  'body' => '{
  "incoming": {
    "investment income": "Income earned from investments.",
    "other income": "Income not covered by another available category.",
    "salary": "Income paid by an employer as wages or salary."
  },
  "outgoing": {
    "entertainment": "Payment for recreation or entertainment.",
    "groceries": "Purchase of food and household staples.",
    "rent": "Payment for ongoing use of a residence or property.",
    "utilities": "Payment for household utility services."
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Api-Key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.ntropy.com/v3/categories/id");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"incoming\": {\n    \"investment income\": \"Income earned from investments.\",\n    \"other income\": \"Income not covered by another available category.\",\n    \"salary\": \"Income paid by an employer as wages or salary.\"\n  },\n  \"outgoing\": {\n    \"entertainment\": \"Payment for recreation or entertainment.\",\n    \"groceries\": \"Purchase of food and household staples.\",\n    \"rent\": \"Payment for ongoing use of a residence or property.\",\n    \"utilities\": \"Payment for household utility services.\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "X-Api-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "incoming": [
    "investment income": "Income earned from investments.",
    "other income": "Income not covered by another available category.",
    "salary": "Income paid by an employer as wages or salary."
  ],
  "outgoing": [
    "entertainment": "Payment for recreation or entertainment.",
    "groceries": "Purchase of food and household staples.",
    "rent": "Payment for ongoing use of a residence or property.",
    "utilities": "Payment for household utility services."
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.ntropy.com/v3/categories/id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```