{
  "openapi": "3.0.1",
  "info": {
    "title": "Custom Fields APIs",
    "description": "Custom fields represent additional attributes that can be associated with package-related data. These fields are created and managed through the platform UI and are exposed via APIs for integration and data retrieval purposes.",
    "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/platformapis",
      "description": "Sandbox Server"
    },
    {
      "url": "https://api.sendpro360.pitneybowes.com/platformapis",
      "description": "Production Server (uses live data)"
    }
  ],
  "tags": [
    {
      "name": "Custom Fields",
      "description": "APIs for retrieving custom field definitions configured in the platform."
    }
  ],
  "paths": {
    "/api/v1/customfields": {
      "get": {
        "tags": [
          "Custom Fields"
        ],
        "summary": "Get Custom Fields",
        "description": "This operation retrieves the list of custom fields defined on the platform. <br/>\nCustom fields are additional package fields that can be displayed on PitneyTrack workflow pages.Custom fields can be created from `My Settings > Custom Fields > Add Custom Field` in the platform settings.\n",
        "operationId": "getCustomField",
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "description": "The page number of the results to retrieve. Pagination starts from 0.",
            "schema": {
              "type": "integer"
            },
            "example": "0",
            "required": false
          },
          {
            "name": "limit",
            "in": "query",
            "description": "The number of custom fields to retrieve per page.",
            "schema": {
              "type": "integer"
            },
            "example": "25",
            "required": false
          },
          {
            "name": "searchBy",
            "in": "query",
            "description": "Search criteria for custom fields.",
            "schema": {
              "type": "string"
            },
            "example": "status:ACTIVE, name:customFieldName"
          },
          {
            "name": "query",
            "in": "query",
            "description": "Search by name for custom fields.",
            "schema": {
              "type": "string"
            },
            "example": "name:customFieldName"
          }
        ],
        "responses": {
          "200": {
            "description": "Custom fields fetched successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CustomFieldsResponse"
                }
              }
            }
          },
          "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/customfields/{customFieldId}": {
      "get": {
        "tags": [
          "Custom Fields"
        ],
        "summary": "Get Custom Field By ID",
        "description": "Retrieves the details of a custom field using its unique custom field ID.<br/>Custom fields can be created from `My Settings > Custom Fields > Add Custom Field` in the platform settings",
        "operationId": "getCustomFieldById",
        "parameters": [
          {
            "name": "customFieldId",
            "in": "path",
            "description": "The unique identifier of the custom field to retrieve.",
            "schema": {
              "type": "string"
            },
            "required": true,
            "example": "mMa0VjWvqbk8"
          }
        ],
        "responses": {
          "200": {
            "description": "Requested Custom Field has been retrived successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/CustomField"
                    }
                  ]
                }
              }
            }
          },
          "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": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "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"
                }
              }
            }
          }
        }
      },
      "PageInfo": {
        "type": "object",
        "properties": {
          "totalCount": {
            "type": "integer",
            "description": "The total number of items available across all pages.",
            "example": 30
          },
          "startCount": {
            "type": "integer",
            "description": "The starting position of the first item on the current page.",
            "example": 1
          },
          "limit": {
            "type": "integer",
            "description": "The maximum number of items that can be displayed on a single page.",
            "example": 20
          }
        }
      },
      "CustomField": {
        "type": "object",
        "properties": {
          "customFieldId": {
            "type": "string",
            "description": " A unique identifier assigned to the custom field.",
            "example": "mMa0VjWvqbk8"
          },
          "name": {
            "type": "string",
            "description": "The name of the custom field used for identification.",
            "example": "Shelf#"
          },
          "customFieldType": {
            "type": "string",
            "description": "Specifies the type of custom field.",
            "example": "CHECKBOX",
            "enum": [
              "TEXT",
              "RADIO",
              "CHECKBOX"
            ]
          },
          "defaultValue": {
            "type": "string",
            "description": "The default value assigned to the custom field if no input is provided.",
            "example": "top"
          },
          "status": {
            "type": "string",
            "description": "Current status of Custom field.",
            "example": "ACTIVE",
            "enum": [
              "ACTIVE",
              "INACTIVE"
            ]
          },
          "archived": {
            "type": "boolean",
            "description": "If the custom field has been deleted or archived.",
            "example": false
          },
          "values": {
            "description": " The value(s) assigned to the custom field. This parameter can hold either a single value or multiple values .",
            "oneOf": [
              {
                "type": "string",
                "description": "Single value for the custom field.",
                "example": "Male"
              },
              {
                "type": "array",
                "description": "List of values for the custom field.",
                "items": {
                  "type": "string"
                },
                "example": [
                  "Male",
                  "Female"
                ]
              }
            ]
          },
          "assignPageForm": {
            "type": "array",
            "description": "A list of pages where the custom field is applied or assigned.",
            "items": {
              "type": "string",
              "example": "Receive, Edit, Deliver, Pouch"
            }
          }
        }
      },
      "CustomFieldsResponse": {
        "type": "object",
        "properties": {
          "pageInfo": {
            "$ref": "#/components/schemas/PageInfo"
          },
          "customFields": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CustomField"
            }
          }
        }
      }
    },
    "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"
            }
          }
        }
      }
    }
  }
}