---
updatedAt: 2026-07-08T07:28:10.000Z
agentTools:
  projectIndex: https://pennylane.readme.io/llms.txt
---

# Link Analytical Categories to a Ledger Entry line

This endpoint replaces already existing categories on the Ledger Entry line with new values.
If an empty array of categories_ids is provided, it will remove all categories from the Ledger Entry line.


> ℹ️
> This endpoint requires the following scope: `ledger_entries:all`

<br />

<Callout icon="ℹ️" theme="info">
  ###

  This endpoint requires one of the following scopes: `ledger_entries:all`
</Callout>

<br />

# OpenAPI definition

```json
{
  "openapi": "3.0.1",
  "info": {
    "title": "Company V2",
    "description": "Automate your accounting with the Pennylane API. [Documentation](https://pennylane.readme.io/)",
    "contact": {
      "email": "tech@pennylane.com"
    },
    "version": "2.0"
  },
  "x-readme": {
    "samples-languages": [
      "curl",
      "node",
      "ruby",
      "php",
      "python",
      "java"
    ]
  },
  "servers": [
    {
      "url": "https://app.pennylane.com"
    }
  ],
  "paths": {
    "/api/external/v2/ledger_entry_lines/{ledger_entry_line_id}/categories": {
      "put": {
        "operationId": "putLedgerEntryLinesCategories",
        "summary": "Link Analytical Categories to a Ledger Entry line",
        "description": "This endpoint replaces already existing categories on the Ledger Entry line with new values.\nIf an empty array of categories_ids is provided, it will remove all categories from the Ledger Entry line.\n\n\n> ℹ️\n> This endpoint requires the following scope: `ledger_entries:all`",
        "tags": [
          "Ledger Entry Lines"
        ],
        "security": [
          {
            "oauth2": [
              "ledger_entries:all"
            ]
          }
        ],
        "parameters": [
          {
            "name": "ledger_entry_line_id",
            "description": "Existing Ledger Entry line (id)",
            "in": "path",
            "schema": {
              "type": "number"
            },
            "required": true
          },
          {
            "name": "X-Company-Id",
            "description": "Numeric ID of the company to act on. Required when authenticating with a firm token. Ignored when the token is already bound to a company.",
            "in": "header",
            "schema": {
              "type": "string",
              "example": "12345"
            },
            "required": false
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "integer",
                      "format": "int64",
                      "example": 394
                    },
                    "weight": {
                      "description": "A number between `0` and `1`, including `1`. It must have a maximum of 7 decimals. `0.85` means 85%.",
                      "type": "string",
                      "example": "0.6575"
                    }
                  },
                  "required": [
                    "id",
                    "weight"
                  ]
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Returns the Ledger Entry line with attached Analytical Categories",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "ledger_entry_line": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "id": {
                          "type": "integer",
                          "format": "int64",
                          "example": 2
                        },
                        "label": {
                          "type": "string",
                          "example": "Employee - remuneration and contributions"
                        },
                        "categories": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "additionalProperties": false,
                            "properties": {
                              "id": {
                                "type": "integer",
                                "format": "int64",
                                "example": 421
                              },
                              "label": {
                                "type": "string",
                                "example": "HR - Salaries"
                              },
                              "weight": {
                                "type": "string",
                                "example": "0.25"
                              },
                              "category_group": {
                                "type": "object",
                                "additionalProperties": false,
                                "properties": {
                                  "id": {
                                    "type": "integer",
                                    "format": "int64",
                                    "example": 229
                                  }
                                },
                                "required": [
                                  "id"
                                ]
                              },
                              "analytical_code": {
                                "type": "string",
                                "nullable": true,
                                "example": "CODE123"
                              },
                              "created_at": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2023-08-30T10:08:08.146343Z"
                              },
                              "updated_at": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2023-08-30T10:08:08.146343Z"
                              },
                              "ledger_account": {
                                "description": "The ledger account the category is wired to, or `null` when none is set.",
                                "type": "object",
                                "nullable": true,
                                "additionalProperties": false,
                                "properties": {
                                  "id": {
                                    "type": "integer",
                                    "format": "int64",
                                    "example": 124
                                  },
                                  "url": {
                                    "description": "The URL to the ledger account",
                                    "type": "string",
                                    "example": "https://app.pennylane.com/api/external/v2/ledger_accounts/124"
                                  }
                                },
                                "required": [
                                  "id",
                                  "url"
                                ]
                              }
                            },
                            "required": [
                              "id",
                              "label",
                              "weight",
                              "category_group",
                              "analytical_code",
                              "created_at",
                              "updated_at",
                              "ledger_account"
                            ]
                          }
                        }
                      },
                      "required": [
                        "id",
                        "label",
                        "categories"
                      ]
                    }
                  },
                  "required": [
                    "ledger_entry_line"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "error": {
                          "type": "string"
                        },
                        "status": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "error",
                        "status"
                      ]
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ]
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "InvalidDateFormat",
                            "InvalidDateTimeFormat",
                            "InvalidEmailFormat",
                            "InvalidPattern",
                            "InvalidUUIDFormat",
                            "LessThanExclusiveMinimum",
                            "LessThanMinimum",
                            "LessThanMinItems",
                            "LessThanMinLength",
                            "MoreThanExclusiveMaximum",
                            "MoreThanMaximum",
                            "MoreThanMaxItems",
                            "MoreThanMaxLength",
                            "NotAMultipartFile",
                            "NotAnyOf",
                            "NotEnumInclude",
                            "NotExistContentTypeDefinition",
                            "NotExistDiscriminatorMappedSchema",
                            "NotExistDiscriminatorPropertyName",
                            "NotExistPropertyDefinition",
                            "NotExistRequiredKey",
                            "NotExistStatusCodeDefinition",
                            "NotNullError",
                            "NotOneOf",
                            "ValidateError"
                          ]
                        }
                      },
                      "required": [
                        "message",
                        "code"
                      ]
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "field": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "InvalidDateFormat",
                            "InvalidDateTimeFormat",
                            "InvalidEmailFormat",
                            "InvalidPattern",
                            "InvalidUUIDFormat",
                            "LessThanExclusiveMinimum",
                            "LessThanMinimum",
                            "LessThanMinItems",
                            "LessThanMinLength",
                            "MoreThanExclusiveMaximum",
                            "MoreThanMaximum",
                            "MoreThanMaxItems",
                            "MoreThanMaxLength",
                            "NotAMultipartFile",
                            "NotAnyOf",
                            "NotEnumInclude",
                            "NotExistContentTypeDefinition",
                            "NotExistDiscriminatorMappedSchema",
                            "NotExistDiscriminatorPropertyName",
                            "NotExistPropertyDefinition",
                            "NotExistRequiredKey",
                            "NotExistStatusCodeDefinition",
                            "NotNullError",
                            "NotOneOf",
                            "ValidateError"
                          ]
                        }
                      },
                      "required": [
                        "message",
                        "field",
                        "code"
                      ]
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "payload": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "InvalidDateFormat",
                            "InvalidDateTimeFormat",
                            "InvalidEmailFormat",
                            "InvalidPattern",
                            "InvalidUUIDFormat",
                            "LessThanExclusiveMinimum",
                            "LessThanMinimum",
                            "LessThanMinItems",
                            "LessThanMinLength",
                            "MoreThanExclusiveMaximum",
                            "MoreThanMaximum",
                            "MoreThanMaxItems",
                            "MoreThanMaxLength",
                            "NotAMultipartFile",
                            "NotAnyOf",
                            "NotEnumInclude",
                            "NotExistContentTypeDefinition",
                            "NotExistDiscriminatorMappedSchema",
                            "NotExistDiscriminatorPropertyName",
                            "NotExistPropertyDefinition",
                            "NotExistRequiredKey",
                            "NotExistStatusCodeDefinition",
                            "NotNullError",
                            "NotOneOf",
                            "ValidateError"
                          ]
                        }
                      },
                      "required": [
                        "message",
                        "payload",
                        "code"
                      ]
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "field": {
                          "type": "string"
                        },
                        "payload": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "enum": [
                            "InvalidDateFormat",
                            "InvalidDateTimeFormat",
                            "InvalidEmailFormat",
                            "InvalidPattern",
                            "InvalidUUIDFormat",
                            "LessThanExclusiveMinimum",
                            "LessThanMinimum",
                            "LessThanMinItems",
                            "LessThanMinLength",
                            "MoreThanExclusiveMaximum",
                            "MoreThanMaximum",
                            "MoreThanMaxItems",
                            "MoreThanMaxLength",
                            "NotAMultipartFile",
                            "NotAnyOf",
                            "NotEnumInclude",
                            "NotExistContentTypeDefinition",
                            "NotExistDiscriminatorMappedSchema",
                            "NotExistDiscriminatorPropertyName",
                            "NotExistPropertyDefinition",
                            "NotExistRequiredKey",
                            "NotExistStatusCodeDefinition",
                            "NotNullError",
                            "NotOneOf",
                            "ValidateError"
                          ]
                        }
                      },
                      "required": [
                        "message",
                        "field",
                        "payload",
                        "code"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Access token is missing or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "The access token is invalid"
                    },
                    "status": {
                      "type": "integer",
                      "example": 401
                    }
                  },
                  "required": [
                    "error",
                    "status"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Access to this resource forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Access to this resource requires scope \"ledger\"."
                    },
                    "status": {
                      "type": "integer",
                      "example": 403
                    }
                  },
                  "required": [
                    "error",
                    "status"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "The resource was not found",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Not Found"
                    },
                    "status": {
                      "type": "integer",
                      "example": 404
                    }
                  },
                  "required": [
                    "error",
                    "status"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable content",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "string",
                      "example": "Entry lines are not balanced"
                    },
                    "status": {
                      "type": "integer",
                      "example": 422
                    }
                  },
                  "required": [
                    "error",
                    "status"
                  ]
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://app.pennylane.com/oauth/authorize",
            "tokenUrl": "https://app.pennylane.com/oauth/oauth/token",
            "refreshUrl": "https://app.pennylane.com/oauth/oauth/token",
            "scopes": {
              "ledger": "Grant create, update and read access to Ledger Entries and its related resources"
            }
          }
        }
      }
    }
  }
}
```