# Appointments

## About - Information about message about this API

 - [GET /api/appointment/about](https://developer.cargosprint.com/pregate/openapi/appointments/paths/~1api~1appointment~1about/get.md)

## GetAppointments - Get list of appointments based on the provided search criteria

 - [POST /api/appointment/getappointments](https://developer.cargosprint.com/pregate/openapi/appointments/paths/~1api~1appointment~1getappointments/post.md): This API queries the appointment database to return appointments matching the specified filters.
Results are paginated and sorted by appointment start date (descending), then by truck visit ID (descending).

Request Fields:
- GateApptStart_DtTm (required): Start of the date range filter. Accepted formats: yyyy-MM-ddTHH:mm:ss, yyyy-MM-dd HH:mm:ss, yyyy-MM-dd.
- GateApptEnd_DtTm (required): End of the date range filter. Must be greater than or equal to GateApptStart_DtTm. If the range exceeds 30 days, only the most recent 30 days of data will be returned.
- ApptType_Cd (optional): Comma-separated appointment type codes to filter by (e.g., "IP,EF").
- ApptStatus_Cd (optional): Comma-separated appointment status codes to filter by (e.g., "C,P").
- Facility_Cd (optional): Comma-separated facility codes to filter by (e.g., "PCT,ITS").
- CargoRef_Num (optional): Comma-separated cargo reference numbers to filter by.
- Container_Num (optional): Comma-separated container numbers to filter by.
- Page (optional, default: 1): Page number for pagination. Must be a positive integer.
- Page_Size (optional, default: 50): Number of records per page. Must be between 1 and 1000.
Response:
The response contains a status indicator and a list of visits, each containing visit-level details and associated moves with appointment information including type, status, container, shipping line, and timestamps.

## TruckVisitDetails - Get detailed appointment information for a specific truck visit

 - [GET /api/appointment/truckvisitdetails](https://developer.cargosprint.com/pregate/openapi/appointments/paths/~1api~1appointment~1truckvisitdetails/get.md): This API queries the appointment database to return comprehensive visit-level and move-level details
for the specified truck visit ID, including associated validation messages for each move.

Request Parameter:
- sVisitId (required): The unique truck visit identifier. Must be a valid numeric value (e.g., "2505094394319").
Response:
The response contains:
- Status: A status code and reason phrase indicating the result of the request.
- Visit: Visit-level details including TruckVisit_Id, business date, calendar date, visit time window (VisitFrom_Tm, VisitTo_Tm), truck plate number, facility code, trucking company SCAC, company name, visit display name, external visit reference number, and dual transaction flag.
- Moves: A list of moves associated with the visit, each containing appointment ID, appointment time window, appointment type and status (code and description), TOS status, container number, cargo reference, chassis number, genset number, shipping line, equipment ISO code, block info, vessel/voyage, seal numbers, external appointment reference, error severity, cancellation info, and create/modify timestamps.
- Messages: Each move includes a list of validation/error messages with error number, description, and severity indicator.

## GetCompanyInfo - Get all company information for the authenticated user based on their affiliations

 - [GET /api/appointment/getcompanyinfo](https://developer.cargosprint.com/pregate/openapi/appointments/paths/~1api~1appointment~1getcompanyinfo/get.md): This API returns a list of all trucking companies the authenticated user has access to,
derived from their UserAffiliations for the current application context. Only companies
with a CompanyType_Cd of "T" (Trucking) are included.
The primary company is listed first, followed by remaining companies sorted alphabetically by name.

Request:
No request body is required. The authenticated user's identity and affiliations are resolved from the authorization token.
Response:
The response contains:
- Companies: A list of company records, each containing:
    - Company_Id: The internal company identifier.
    - Company_Uid: The SSO company unique identifier (GUID).
    - Company_Nm: The company name.
    - SCAC: The Standard Carrier Alpha Code for the trucking company.
    - CompanyType_Cd: The company type code (e.g., "T" for Trucking).
    - IsPrimary: Indicates whether this is the user's primary affiliated company.
- TotalCount: The total number of companies returned.
Notes:
- If the user has no company affiliations or no matching companies are found in the database, an empty list with TotalCount of 0 is returned.

## GetAvailableTimeSlots - Get available appointment time slots based on the provided visit and move details

 - [POST /api/appointment/getavailabletimeslots](https://developer.cargosprint.com/pregate/openapi/appointments/paths/~1api~1appointment~1getavailabletimeslots/post.md): This API performs a two-step process:

1. Payload Validation – Before retrieving slots, the API validates the submitted data. 
If critical errors are found (e.g., missing or invalid fields), the request will return 
appropriate validation messages without proceeding to slot retrieval.
2. Slot Lookup – If the payload passes validation without any critical errors, 
the API proceeds to search for and return a list of available appointment slots 
that match the specified criteria.

## GetBookingDetails - Get booking details for the specified booking numbers and optional terminal operator

 - [POST /api/appointment/getbookingdetails](https://developer.cargosprint.com/pregate/openapi/appointments/paths/~1api~1appointment~1getbookingdetails/post.md): This API retrieves booking/EDO details from the BRE API for a given list of booking numbers.

Request Fields:
- BookingNumbers (required): An array of booking number strings to look up (e.g., ["BKG001", "BKG002"]).
- MTO_Cd (optional): The terminal operator code (e.g., "PCT", "ITS"). When provided, the system resolves it to the corresponding MTO_Id for routing the request to the correct terminal's BRE API.
Response:
The response contains:
- Status: A status code and reason phrase indicating the result.
- Bookings: A list of booking records, each containing MTO_Id, booking number, shipping line SCAC, ordered quantity, appointment count, equipment orders, hazmat/reefer/OD flags, POD, PDL, and fee items.

## CreateUpdateAppointment - Creates or updates appointments with a lighter payload designed for external APIM consumers

 - [POST /api/appointment/createupdateappointment](https://developer.cargosprint.com/pregate/openapi/appointments/paths/~1api~1appointment~1createupdateappointment/post.md): This API is called by external customers through APIM. APIM authenticates the client and derives
the Bearer Token and Request Source Identifier, which are passed to this API via request headers.

Request Fields:
- IndexedClientVisitRequests (required): A list of visit requests, each containing:
    - Facility_Cd (required): The facility code (e.g., "ITS", "PCT").
    - Trkc_Scac (required): The trucking company SCAC code.
    - TruckPlate_Num: The truck plate number.
    - Driver_Name: The driver name.
    - TruckVisit_Id: The existing truck visit ID (0 for new).
    - VisitMoveDate (required): The visit/move date (format: yyyy-MM-dd).
    - Moves (required): A list of moves, each containing:
        - UserAction (required): A = Add, E = Edit, C = Check IN, R = Reschedule.
        - GateAppt_Id: The existing appointment ID (0 for new).
        - Pool_Id: The pool ID representing a filter matching the appointment data.
        - ApptType_Cd (required): The appointment type code (e.g., "IP", "EF").
        - Container_Num, ShippingLine_Cd, EquipmentIso_Cd, etc.
        - Tare_Weight: Optional tare weight value.
        - Tare_Weight_UOM: Unit of measurement (kg, lb, tn, t).
Headers:
- Authorization: Bearer token derived by APIM.
- X-Request-Source-Identifier: Request source identifier derived by APIM.

## CancelAppointment - Cancels appointment moves or an entire visit

 - [POST /api/appointment/cancelappointment](https://developer.cargosprint.com/pregate/openapi/appointments/paths/~1api~1appointment~1cancelappointment/post.md): Cancels either individual moves or the entire appointment (visit) depending on the provided input.
Supports two ways of identifying what should be canceled:

- gateApptIdList: Cancel specific moves by Gate Appointment ID.
- truckVisitIdList: Cancel the entire visit by Truck Visit ID.
Each entry requires an Id and either MTO_Id or MTO_Cd to identify the terminal.

