{
  "openapi": "3.0.1",
  "info": {
    "title": "Overview",
    "description": "CRUD operations to manage **billing codes** and **company codes**.\nA billing code is a customer-defined identifier (e.g., an account or company) that can be attached to shipments, invoices, or reports.\n",
    "version": "1.0.0",
    "license": {
      "name": "PB Software License Agreement",
      "url": "https://www.pitneybowes.com/us/support/account/pitney-bowes-terms-and-conditions.html"
    }
  },
  "servers": [
    {
      "url": "https://api-sandbox.sendpro360.pitneybowes.com/costaccountmgmt",
      "description": "Sandbox Server"
    },
    {
      "url": "https://api.sendpro360.pitneybowes.com/costaccountmgmt",
      "description": "Production Server (uses live data)"
    }
  ],
  "tags": [
    {
      "name": "Account Code",
      "description": "APIs for managing account codes."
    },
    {
      "name": "Company Code",
      "description": "APIs for managing company codes."
    }
  ],
  "paths": {
    "/api/v1/accountCodes": {
      "post": {
        "tags": [
          "Account Code"
        ],
        "summary": "Create Account Code",
        "description": "Creates a new Account Code record. The `code` should be unique per tenant.",
        "operationId": "createAccountCode",
        "parameters": [
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "This is the Developer Partner ID. When the developer is the only partner, this field is not required.",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateAccountCodeRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Account Code has been generated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountCodeCreated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or Bad Request",
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "description": "Unauthorized Error",
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "description": "Internal Server Error",
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "get": {
        "tags": [
          "Account Code"
        ],
        "summary": "Get Account Codes",
        "description": "Returns a list of Account Codes.  \nUse `sortBy` to sort results by a supported field and direction.\n",
        "operationId": "getAccountCodes",
        "parameters": [
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "description": "This is the Developer Partner ID. When the developer is the only partner, this field is not required.",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "sortBy",
            "schema": {
              "type": "string",
              "example": "code:asc"
            },
            "description": "Sort by field and direction (e.g., code:asc, code:desc)."
          }
        ],
        "responses": {
          "200": {
            "description": "A list of Account Code has been retrieved successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/AccountCodeListItem"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid or Bad Request",
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "description": "Unauthorized Error",
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "description": "Internal Server Error",
            "$ref": "#/components/responses/InternalServerError"
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/accountCodes/{id}": {
      "get": {
        "tags": [
          "Account Code"
        ],
        "summary": "Get Account Code by ID",
        "description": "Retrieves a single Account Code by its unique `id`.",
        "operationId": "getAccountCodeById",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Unique identifier of the Account Code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "description": "This is the Developer Partner ID. When the developer is the only partner, this field is not required.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Specified Account Code has been retrieved successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountCode"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or Bad Request",
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "description": "Unauthorized Error",
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "description": "Internal Server Error",
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "put": {
        "tags": [
          "Account Code"
        ],
        "summary": "Update Account Code",
        "description": "Update the `code` and/or `description` for the specified `id`. Use this to revise an Account Code record.",
        "operationId": "updateAccountCode",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Unique identifier of the Account Code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "description": "This is the Developer Partner ID. When the developer is the only partner, this field is not required.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateAccountCodeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Specified Account Code has been updated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountCodeUpdated"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or Bad Request",
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "description": "Unauthorized Error",
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "description": "Internal Server Error",
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "delete": {
        "tags": [
          "Account Code"
        ],
        "summary": "Delete Account Code",
        "description": "Deletes the Account Code identified by `id`.",
        "operationId": "deleteAccountCodeById",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Unique identifier of the Account Code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "description": "This is the Developer Partner ID. When the developer is the only partner, this field is not required.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Specified Account Code has been deleted successfully."
          },
          "400": {
            "description": "Invalid or Bad Request",
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "description": "Unauthorized Error",
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "description": "Internal Server Error"
          }
        }
      }
    },
    "/api/v1/companyCodes": {
      "post": {
        "tags": [
          "Company Code"
        ],
        "summary": "Create Company Code",
        "description": "Creates a new Company Code record. The `code` must be unique per tenant.",
        "operationId": "createCompanyCode",
        "parameters": [
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "Developer Partner ID. Not required if the developer is the only partner.",
            "required": false
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateCompanyCodeRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Company Code has been created successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyCodeCreated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "get": {
        "tags": [
          "Company Code"
        ],
        "summary": "Get Company Codes",
        "description": "Returns a list of Company Codes.\n",
        "operationId": "getCompanyCodes",
        "parameters": [
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "description": "Developer Partner ID. Not required if the developer is the only partner.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "A list of Company Codes has been retrieved successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CompanyCodeListItem"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    },
    "/api/v1/companyCodes/{id}": {
      "get": {
        "tags": [
          "Company Code"
        ],
        "summary": "Get Company Code by ID",
        "description": "Retrieves a single Company Code by its unique `id`.",
        "operationId": "getCompanyCodeById",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Unique identifier of the Company Code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "description": "Developer Partner ID. Not required if the developer is the only partner.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Specified Company Code has been retrieved successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyCode"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "put": {
        "tags": [
          "Company Code"
        ],
        "summary": "Update Company Code",
        "description": "Update the `code` and/or `description` for the specified `id`.\n",
        "operationId": "updateCompanyCode",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Unique identifier of the Company Code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "description": "Developer Partner ID. Not required if the developer is the only partner.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UpdateCompanyCodeRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Specified Company Code has been updated successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CompanyCodeUpdated"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      },
      "delete": {
        "tags": [
          "Company Code"
        ],
        "summary": "Delete Company Code",
        "description": "Deletes the Company Code identified by `id`.",
        "operationId": "deleteCompanyCodeById",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "description": "Unique identifier of the Company Code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-PB-Developer-Partner-ID",
            "in": "header",
            "description": "Developer Partner ID. Not required if the developer is the only partner.",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "Specified Company Code has been deleted successfully."
          },
          "400": {
            "$ref": "#/components/responses/BadRequestError"
          },
          "401": {
            "$ref": "#/components/responses/UnauthorizedError"
          },
          "500": {
            "$ref": "#/components/responses/InternalServerError"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "responses": {
      "UnauthorizedError": {
        "description": "The request could not be authorized.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/error"
            }
          }
        }
      },
      "InternalServerError": {
        "description": "The request could not be completed due to an internal error.",
        "content": {}
      },
      "BadRequestError": {
        "description": "Invalid request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Errors"
            }
          }
        }
      }
    },
    "schemas": {
      "error": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "description": "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."
          }
        },
        "required": [
          "message"
        ]
      },
      "Errors": {
        "type": "object",
        "properties": {
          "errors": {
            "type": "array",
            "description": "List of errors.",
            "items": {
              "type": "object",
              "properties": {
                "errorCode": {
                  "type": "string",
                  "description": "This error can be validation_error or internal_error or not_found or already_exists",
                  "example": "validation_error"
                },
                "errorDescription": {
                  "type": "string",
                  "description": "The HTTP 400 Bad Request response status code indicates that the server cannot process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).",
                  "example": "Custom Fields not found"
                }
              }
            }
          }
        }
      },
      "CreateAccountCodeRequest": {
        "type": "object",
        "required": [
          "code"
        ],
        "description": "Request body for creating an Account Code.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Customer-defined Account Code value (must be unique per tenant).",
            "example": "278001"
          },
          "description": {
            "type": "string",
            "description": "Human-readable description for the Account Code.",
            "example": "this is description for test code 278001"
          }
        }
      },
      "UpdateAccountCodeRequest": {
        "type": "object",
        "description": "Request body to update an Account Code.",
        "properties": {
          "code": {
            "type": "string",
            "description": "New/updated Account Code value.",
            "example": "278001"
          },
          "description": {
            "type": "string",
            "description": "Updated description of the Account Code.",
            "example": "this is description for test codehash278001-u1"
          }
        }
      },
      "AccountCodeCreated": {
        "type": "object",
        "description": "Response payload returned after creating an Account Code.",
        "properties": {
          "id": {
            "type": "string",
            "description": "System-generated identifier of the created Account Code.",
            "example": "d8WpwWzlMgYO"
          }
        }
      },
      "AccountCodeUpdated": {
        "type": "object",
        "description": "Response payload returned after updating an Account Code.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Identifier of the updated Account Code.",
            "example": "d8WpwWzlMgYO"
          }
        }
      },
      "AccountCode": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the Account Code created by system.",
            "example": "d8WpwWzlMgYO"
          },
          "code": {
            "type": "string",
            "description": "This is unique Account Code.",
            "example": "280002"
          },
          "description": {
            "type": "string",
            "description": "Account Code description.",
            "example": "this is description for test codehash280002"
          }
        }
      },
      "AccountCodeListItem": {
        "type": "object",
        "description": "Account Code record returned by the system.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the Account Code created by system.",
            "example": "da5l9bkOMml5"
          },
          "code": {
            "type": "string",
            "description": "Unique Account Code value.",
            "example": "278001"
          },
          "description": {
            "type": "string",
            "description": "Account Code description.",
            "example": "This is description for test codehash278001-u1"
          }
        }
      },
      "CreateCompanyCodeRequest": {
        "type": "object",
        "required": [
          "code"
        ],
        "description": "Request body for creating a Company Code.",
        "properties": {
          "code": {
            "type": "string",
            "description": "Customer-defined Company Code value (must be unique per tenant).",
            "example": "COMP001"
          },
          "description": {
            "type": "string",
            "description": "Human-readable description for the Company Code.",
            "example": "This is description for test company code COMP001"
          }
        }
      },
      "UpdateCompanyCodeRequest": {
        "type": "object",
        "description": "Request body to update a Company Code.",
        "properties": {
          "code": {
            "type": "string",
            "description": "New or updated Company Code value.",
            "example": "COMP001"
          },
          "description": {
            "type": "string",
            "description": "Updated description of the Company Code.",
            "example": "This is description for updated company code COMP001-u1"
          }
        }
      },
      "CompanyCodeCreated": {
        "type": "object",
        "description": "Response payload returned after creating a Company Code.",
        "properties": {
          "id": {
            "type": "string",
            "description": "System-generated identifier of the created Company Code.",
            "example": "cmpy12345xyz"
          }
        }
      },
      "CompanyCodeUpdated": {
        "type": "object",
        "description": "Response payload returned after updating a Company Code.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Identifier of the updated Company Code.",
            "example": "cmpy12345xyz"
          }
        }
      },
      "CompanyCode": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the Company Code created by the system.",
            "example": "cmpy12345xyz"
          },
          "code": {
            "type": "string",
            "description": "Unique Company Code value.",
            "example": "COMP002"
          },
          "description": {
            "type": "string",
            "description": "Description of the Company Code.",
            "example": "This is description for test company code COMP002"
          }
        }
      },
      "CompanyCodeListItem": {
        "type": "object",
        "description": "Company Code record returned by the system.",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique identifier of the Company Code created by the system.",
            "example": "cmpy6789abc"
          },
          "code": {
            "type": "string",
            "description": "Unique Company Code value.",
            "example": "COMP001"
          },
          "description": {
            "type": "string",
            "description": "Company Code description.",
            "example": "This is description for updated company code COMP001-u1"
          }
        }
      }
    }
  }
}