# Add Cost Account

This operation creates cost account. <br>
**Key Considerations:**
- A cost account is an account used to maintain and segregate records for shipments, postage, and other operational data. There can be multiple Cost accounts, I.e; multiple Wallet - but one ledger.
- Cost accounts allow to track which wallet was used for payment, maintain detailed payment history, and set budget notifications or thresholds.
- Cost accounts are managed in a hierarchical structure: Enterprise > Division > Location.
- Cost accounts can be assigned to a location, enabling client administrators to filter and analyze records based on the selected cost account.
- A location can have one or more cost accounts assigned to it. This allows to filter shipments or postage records by selecting the cost account.
- Cost accounts are assigned a status of either Active or Inactive.
- Sub-Cost Accounts and Sub-Sub-Cost Accounts can also be created under the main cost account to further refine segregation.

Endpoint: POST /api/v1/costAccounts
Version: 1.0.0
Security: bearerAuth

## Header parameters:

  - `X-PB-Developer-Partner-ID` (string)
    This is the Developer Partner ID. When the developer is the only partner, this field is not required.

## Request fields (application/json):

  - `name` (string, required)
    Name of the cost account. When used in Shipment APIs, this field is referred to as `costAccountName`.
    Example: testname

  - `code` (string, required)
    Code of the cost account. When used in Shipment APIs, this field is referred to as `costAccountCode`.
    Example: test01

  - `passwordEnabled` (boolean)
    Set to true when to enable password on cost account
    Example: true

  - `passwordCode` (string)
    Only required when passwordEnabled is true. this indicates the password you want to set. It should be alphanumeric and lenght of 4
    Example: test

  - `description` (string)
    this indicates the description you want to provide for cost account
    Example: test cost account

  - `status` (boolean)
    Setting  true creates cost account as Active and setting false makes it inactive
    Example: true

  - `billable` (boolean)
    set to true in case want to make cost account billable
    Example: true

  - `parent` (string)
    this indicates cost account Id of parent account

  - `advanceOption` (object)
    Additional configuration options for assigning the cost account to a specific  hierarchy level (Enterprise, Division, or Location). If no permission is provided, the cost account is assigned to the Enterprise level by default.
    Example: {"permission":{"permissionByEntity":"D","permissionByValue":["div_auto_sac11be"]}}

  - `advanceOption.permission` (object)
    Defines the hierarchy level and corresponding entity values where this cost account will be available.

  - `advanceOption.permission.permissionByEntity` (string)
    Indicates the hierarchy level at which the cost account is assigned.
Supported values:
    Enum: "D", "L", "E"

  - `advanceOption.permission.permissionByValue` (array)
    The list of identifiers corresponding to the selected hierarchy level.
For example:
Division IDs if permissionByEntity = D 
Location IDs if permissionByEntity = L 
Enterprise ID f permissionByEntity = E

## Response 200 fields (application/json):

  - `accountID` (string)
    Unique cost account id generated by system. When used in Shipment APIs, this field is referred to as `costAccountId`.

## Response 401 fields (application/json):

  - `message` (string, required)
    This is HTTP 401 Unauthorized response status code, that indicates that the client request has not been completed because it lacks valid authentication credentials for the requested resource.

