openapi: 3.0.3 info: title: 'City Courier API Documentation' description: '' version: 1.0.0 servers: - url: 'https://api.citycourier.org/public' tags: - name: Authentication description: "\nAPIs for managing user authentication" - name: 'Cities and Branches' description: "\nAPIs for managing cities and their branches" - name: 'Consignment Management' description: "\nAPIs for managing consignments" - name: Endpoints description: '' paths: /api/v1/login: post: summary: 'User Login' operationId: userLogin description: 'Authenticate a user and return an access token.' parameters: [] responses: 200: description: '' content: application/json: schema: type: object example: success: true data: user: id: 1 loginID: user123 email: user@example.com profile: name: 'John Doe' phone: '+1234567890' token: 1|abcdefghijklmnopqrstuvwxyz message: 'Login successful' properties: success: type: boolean example: true data: type: object properties: user: type: object properties: id: type: integer example: 1 loginID: type: string example: user123 email: type: string example: user@example.com profile: type: object properties: name: type: string example: 'John Doe' phone: type: string example: '+1234567890' token: type: string example: 1|abcdefghijklmnopqrstuvwxyz message: type: string example: 'Login successful' 422: description: '' content: application/json: schema: type: object example: success: false message: 'The provided credentials are incorrect.' properties: success: type: boolean example: false message: type: string example: 'The provided credentials are incorrect.' tags: - Authentication requestBody: required: true content: application/json: schema: type: object properties: loginID: type: string description: "The user's login ID." example: user123 nullable: false email: type: string description: "required_if:loginID,null The user's email address." example: user@example.com nullable: false password: type: string description: "The user's password." example: password123 nullable: false required: - loginID - password security: [] /api/v1/me: get: summary: 'Get Authenticated User' operationId: getAuthenticatedUser description: 'Get the details of the currently authenticated user.' parameters: [] responses: 200: description: '' content: application/json: schema: type: object example: success: true data: user: id: 1 loginID: user123 email: user@example.com profile: name: 'John Doe' phone: '+1234567890' message: 'User details retrieved successfully' properties: success: type: boolean example: true data: type: object properties: user: type: object properties: id: type: integer example: 1 loginID: type: string example: user123 email: type: string example: user@example.com profile: type: object properties: name: type: string example: 'John Doe' phone: type: string example: '+1234567890' message: type: string example: 'User details retrieved successfully' tags: - Authentication /api/v1/cities: get: summary: 'Get all cities' operationId: getAllCities description: 'Retrieve a list of all cities with their basic information.' parameters: [] responses: 200: description: '' content: application/json: schema: type: object example: success: true data: - id: 1 name: 'New York' code: NYC zone: East - id: 2 name: 'Los Angeles' code: LAX zone: West message: 'Cities retrieved successfully' properties: success: type: boolean example: true data: type: array example: - id: 1 name: 'New York' code: NYC zone: East - id: 2 name: 'Los Angeles' code: LAX zone: West items: type: object properties: id: type: integer example: 1 name: type: string example: 'New York' code: type: string example: NYC zone: type: string example: East message: type: string example: 'Cities retrieved successfully' 500: description: '' content: application/json: schema: type: object example: success: false message: 'Internal server error' properties: success: type: boolean example: false message: type: string example: 'Internal server error' tags: - 'Cities and Branches' security: [] '/api/v1/cities/{cityId}/branches': get: summary: 'Get branches by city' operationId: getBranchesByCity description: 'Retrieve all branches for a specific city with their details.' parameters: [] responses: 200: description: '' content: application/json: schema: type: object example: success: true data: - id: 1 name: 'Main Branch' code: NYC-MAIN type: Main city_id: 1 city: id: 1 name: 'New York' code: NYC zone: East - id: 2 name: 'Downtown Branch' code: NYC-DOWN type: Sub city_id: 1 city: id: 1 name: 'New York' code: NYC zone: East message: 'Branches retrieved successfully' properties: success: type: boolean example: true data: type: array example: - id: 1 name: 'Main Branch' code: NYC-MAIN type: Main city_id: 1 city: id: 1 name: 'New York' code: NYC zone: East - id: 2 name: 'Downtown Branch' code: NYC-DOWN type: Sub city_id: 1 city: id: 1 name: 'New York' code: NYC zone: East items: type: object properties: id: type: integer example: 1 name: type: string example: 'Main Branch' code: type: string example: NYC-MAIN type: type: string example: Main city_id: type: integer example: 1 city: type: object properties: id: type: integer example: 1 name: type: string example: 'New York' code: type: string example: NYC zone: type: string example: East message: type: string example: 'Branches retrieved successfully' 404: description: '' content: application/json: schema: type: object example: success: false message: 'City not found' properties: success: type: boolean example: false message: type: string example: 'City not found' 500: description: '' content: application/json: schema: type: object example: success: false message: 'Internal server error' properties: success: type: boolean example: false message: type: string example: 'Internal server error' tags: - 'Cities and Branches' security: [] parameters: - in: path name: cityId description: 'The ID of the city.' example: 1 required: true schema: type: integer /api/v1/consignments: get: summary: 'List all consignments' operationId: listAllConsignments description: "Get a list of all consignments. The results are filtered based on user role:\n- Admin/Manager users can see all consignments\n- Regular users can only see their own consignments" parameters: - in: query name: from_date description: 'Filter consignments created after this date.' example: '2024-03-01' required: false schema: type: string description: 'Filter consignments created after this date.' example: '2024-03-01' nullable: false - in: query name: to_date description: 'Filter consignments created before this date.' example: '2024-03-20' required: false schema: type: string description: 'Filter consignments created before this date.' example: '2024-03-20' nullable: false - in: query name: status description: 'Filter by consignment status (case-insensitive).' example: booked required: false schema: type: string description: 'Filter by consignment status (case-insensitive).' example: booked nullable: false responses: 200: description: '' content: application/json: schema: type: object example: success: true data: - id: 1 consignment_no: NYC-LAX-123456 status: id: 1 name: Booked consigner: name: 'John Doe' phone: '+1234567890' address: '123 Main St' consignee: name: 'Jane Smith' phone: '+1987654321' address: '456 Oak St' branch: id: 1 name: 'Main Branch' created_at: '2024-03-20T10:00:00.000000Z' properties: success: type: boolean example: true data: type: array example: - id: 1 consignment_no: NYC-LAX-123456 status: id: 1 name: Booked consigner: name: 'John Doe' phone: '+1234567890' address: '123 Main St' consignee: name: 'Jane Smith' phone: '+1987654321' address: '456 Oak St' branch: id: 1 name: 'Main Branch' created_at: '2024-03-20T10:00:00.000000Z' items: type: object properties: id: type: integer example: 1 consignment_no: type: string example: NYC-LAX-123456 status: type: object properties: id: type: integer example: 1 name: type: string example: Booked consigner: type: object properties: name: type: string example: 'John Doe' phone: type: string example: '+1234567890' address: type: string example: '123 Main St' consignee: type: object properties: name: type: string example: 'Jane Smith' phone: type: string example: '+1987654321' address: type: string example: '456 Oak St' branch: type: object properties: id: type: integer example: 1 name: type: string example: 'Main Branch' created_at: type: string example: '2024-03-20T10:00:00.000000Z' tags: - 'Consignment Management' security: [] post: summary: 'Create new consignment' operationId: createNewConsignment description: "Create a new consignment with the provided details. The consignment will be created with 'Booked' status.\nDifferent fields are required based on user type (CLIENT vs others)." parameters: [] responses: 201: description: '' content: application/json: schema: type: object example: success: true data: id: 1 consignment_no: NYC-LAX-123456 status_id: 1 volumetric_weight: 8.4 chargeable_weight: 10.5 message: 'Consignment created successfully' properties: success: type: boolean example: true data: type: object properties: id: type: integer example: 1 consignment_no: type: string example: NYC-LAX-123456 status_id: type: integer example: 1 volumetric_weight: type: number example: 8.4 chargeable_weight: type: number example: 10.5 message: type: string example: 'Consignment created successfully' 422: description: '' content: application/json: schema: type: object example: success: false message: 'Validation failed' errors: origin: - 'The origin field is required.' properties: success: type: boolean example: false message: type: string example: 'Validation failed' errors: type: object properties: origin: type: array example: - 'The origin field is required.' items: type: string tags: - 'Consignment Management' requestBody: required: true content: application/json: schema: type: object properties: origin: type: integer description: 'The ID of the origin city.' example: 1 nullable: false destination: type: integer description: 'The ID of the destination city.' example: 2 nullable: false service_type: type: string description: 'The type of service (Overnight/Express).' example: Express nullable: false pieces: type: string description: 'Number of pieces.' example: '2' nullable: false height: type: string description: 'Height of the package.' example: '10.5' nullable: false width: type: string description: 'Width of the package.' example: '15.2' nullable: false length: type: string description: 'Length of the package.' example: '20.0' nullable: false weight: type: string description: 'Weight of the package.' example: '5.5' nullable: false consignerName: type: string description: 'Name of the consigner.' example: 'John Doe' nullable: false consignerPhone: type: string description: 'Phone number of the consigner.' example: '+1234567890' nullable: false consignerAddress: type: string description: 'Address of the consigner.' example: '123 Main St' nullable: false consigneeName: type: string description: 'Name of the consignee.' example: 'Jane Smith' nullable: false consigneePhone: type: string description: 'Phone number of the consignee.' example: '+1987654321' nullable: false consigneeAddress: type: string description: 'Address of the consignee.' example: "456 Oak St\n\nFor CLIENT users, additional fields:" nullable: false consignerPhone2: type: string description: 'optional Secondary phone number of the consigner.' example: '+1234567891' nullable: false consignerCnic: type: string description: 'required_if:user_type,not_client CNIC of the consigner.' example: 12345-6789012-3 nullable: false consigneePhone2: type: string description: 'optional Secondary phone number of the consignee.' example: '+1987654322' nullable: false cod_type: type: string description: 'Type of payment (Prepaid/COD).' example: Prepaid nullable: false orderId: type: string description: 'Order ID.' example: ORD123 nullable: false cod_amount: type: string description: 'required_if:cod_type,COD COD amount.' example: '1000' nullable: false declared_value: type: string description: 'Declared value of the package.' example: '5000' nullable: false special_instructions: type: string description: 'Special instructions.' example: "Handle with care\n\nFor non-CLIENT users, additional fields:" nullable: false goods_description: type: string description: 'Description of goods.' example: Electronics nullable: false price: type: string description: 'Price of the consignment.' example: '1000' nullable: false discount: type: string description: 'Discount amount.' example: '100' nullable: false total_price: type: string description: 'Total price after discount.' example: '900' nullable: false required: - origin - destination - service_type - pieces - height - width - length - weight - consignerName - consignerPhone - consignerAddress - consigneeName - consigneePhone - consigneeAddress - cod_type - orderId - declared_value - special_instructions - goods_description - price - discount - total_price security: [] '/api/v1/consignments/{id}': get: summary: 'Get consignment details' operationId: getConsignmentDetails description: "Retrieve detailed information about a specific consignment. Can be accessed by ID or consignment number.\nRegular users can only access their own consignments." parameters: [] responses: 200: description: '' content: application/json: schema: type: object example: success: true data: id: 1 consignment_no: NYC-LAX-123456 status: id: 1 name: Booked consigner: name: 'John Doe' phone: '+1234567890' address: '123 Main St' cnic: 12345-6789012-3 consignee: name: 'Jane Smith' phone: '+1987654321' address: '456 Oak St' branch: id: 1 name: 'Main Branch' trackings: - id: 1 status: Booked created_at: '2024-03-20T10:00:00.000000Z' originCity: id: 1 name: 'New York' destinationCity: id: 2 name: 'Los Angeles' message: 'Consignment retrieved successfully' properties: success: type: boolean example: true data: type: object properties: id: type: integer example: 1 consignment_no: type: string example: NYC-LAX-123456 status: type: object properties: id: type: integer example: 1 name: type: string example: Booked consigner: type: object properties: name: type: string example: 'John Doe' phone: type: string example: '+1234567890' address: type: string example: '123 Main St' cnic: type: string example: 12345-6789012-3 consignee: type: object properties: name: type: string example: 'Jane Smith' phone: type: string example: '+1987654321' address: type: string example: '456 Oak St' branch: type: object properties: id: type: integer example: 1 name: type: string example: 'Main Branch' trackings: type: array example: - id: 1 status: Booked created_at: '2024-03-20T10:00:00.000000Z' items: type: object properties: id: type: integer example: 1 status: type: string example: Booked created_at: type: string example: '2024-03-20T10:00:00.000000Z' originCity: type: object properties: id: type: integer example: 1 name: type: string example: 'New York' destinationCity: type: object properties: id: type: integer example: 2 name: type: string example: 'Los Angeles' message: type: string example: 'Consignment retrieved successfully' 404: description: '' content: application/json: schema: type: object example: success: false message: 'Consignment not found' properties: success: type: boolean example: false message: type: string example: 'Consignment not found' tags: - 'Consignment Management' security: [] put: summary: 'Update consignment' operationId: updateConsignment description: "Update an existing consignment's details. Only consignments with 'Booked' status can be updated.\nDifferent fields are required based on user type (CLIENT vs others)." parameters: [] responses: 200: description: '' content: application/json: schema: type: object example: success: true data: id: 1 consignment_no: NYC-LAX-123456 status_id: 1 message: 'Consignment updated successfully' properties: success: type: boolean example: true data: type: object properties: id: type: integer example: 1 consignment_no: type: string example: NYC-LAX-123456 status_id: type: integer example: 1 message: type: string example: 'Consignment updated successfully' 400: description: '' content: application/json: schema: type: object example: success: false message: 'Only consignments with Booked status can be updated' properties: success: type: boolean example: false message: type: string example: 'Only consignments with Booked status can be updated' 404: description: '' content: application/json: schema: type: object example: success: false message: 'Consignment not found' properties: success: type: boolean example: false message: type: string example: 'Consignment not found' tags: - 'Consignment Management' requestBody: required: true content: application/json: schema: type: object properties: service_type: type: string description: 'The type of service.' example: Express nullable: false origin: type: integer description: 'The ID of the origin city.' example: 1 nullable: false destination: type: integer description: 'The ID of the destination city.' example: 2 nullable: false pieces: type: string description: 'Number of pieces.' example: '2' nullable: false height: type: string description: 'Height of the package.' example: '10.5' nullable: false width: type: string description: 'Width of the package.' example: '15.2' nullable: false length: type: string description: 'Length of the package.' example: '20.0' nullable: false weight: type: string description: 'Weight of the package.' example: '5.5' nullable: false consignerName: type: string description: 'Name of the consigner.' example: 'John Doe' nullable: false consignerPhone: type: string description: 'Phone number of the consigner.' example: '+1234567890' nullable: false consignerPhone2: type: string description: 'optional Secondary phone number of the consigner.' example: '+1234567891' nullable: false consignerAddress: type: string description: 'Address of the consigner.' example: '123 Main St' nullable: false consignerCnic: type: string description: 'required_if:user_type,not_client CNIC of the consigner.' example: 12345-6789012-3 nullable: false consigneeName: type: string description: 'Name of the consignee.' example: 'Jane Smith' nullable: false consigneePhone: type: string description: 'Phone number of the consignee.' example: '+1987654321' nullable: false consigneePhone2: type: string description: 'optional Secondary phone number of the consignee.' example: '+1987654322' nullable: false consigneeAddress: type: string description: 'Address of the consignee.' example: "456 Oak St\n\nFor CLIENT users, additional fields:" nullable: false cod_type: type: string description: 'Type of payment (Prepaid/COD).' example: Prepaid nullable: false orderId: type: string description: 'Order ID.' example: ORD123 nullable: false cod_amount: type: string description: 'required_if:cod_type,COD COD amount.' example: '1000' nullable: false declared_value: type: string description: 'Declared value of the package.' example: '5000' nullable: false special_instructions: type: string description: 'Special instructions.' example: "Handle with care\n\nFor non-CLIENT users, additional fields:" nullable: false goods_description: type: string description: 'Description of goods.' example: Electronics nullable: false price: type: string description: 'Price of the consignment.' example: '1000' nullable: false discount: type: string description: 'Discount amount.' example: '100' nullable: false total_price: type: string description: 'Total price after discount.' example: '900' nullable: false required: - service_type - origin - destination - pieces - height - width - length - weight - consignerName - consignerPhone - consignerAddress - consigneeName - consigneePhone - consigneeAddress - cod_type - orderId - declared_value - special_instructions - goods_description - price - discount - total_price security: [] delete: summary: 'Delete consignment' operationId: deleteConsignment description: "Delete a specific consignment. Only consignments with 'Booked' status can be deleted.\nRegular users can only delete their own consignments." parameters: [] responses: 200: description: '' content: application/json: schema: type: object example: success: true message: 'Consignment deleted successfully' properties: success: type: boolean example: true message: type: string example: 'Consignment deleted successfully' 400: description: '' content: application/json: schema: type: object example: success: false message: 'Only consignments with Booked status can be deleted' properties: success: type: boolean example: false message: type: string example: 'Only consignments with Booked status can be deleted' 404: description: '' content: application/json: schema: type: object example: success: false message: 'Consignment not found' properties: success: type: boolean example: false message: type: string example: 'Consignment not found' tags: - 'Consignment Management' security: [] parameters: - in: path name: id description: 'The ID or consignment number of the consignment.' example: 0 required: true schema: type: integer '/api/v1/consignments/{id}/tracking': get: summary: 'Get consignment tracking' operationId: getConsignmentTracking description: 'Retrieve tracking information for a specific consignment.' parameters: [] responses: 200: description: '' content: application/json: schema: type: object example: success: true data: - id: 1 consignment_id: 1 status: Booked created_at: '2024-03-20T10:00:00.000000Z' updated_at: '2024-03-20T10:00:00.000000Z' message: 'Consignment tracking retrieved successfully' properties: success: type: boolean example: true data: type: array example: - id: 1 consignment_id: 1 status: Booked created_at: '2024-03-20T10:00:00.000000Z' updated_at: '2024-03-20T10:00:00.000000Z' items: type: object properties: id: type: integer example: 1 consignment_id: type: integer example: 1 status: type: string example: Booked created_at: type: string example: '2024-03-20T10:00:00.000000Z' updated_at: type: string example: '2024-03-20T10:00:00.000000Z' message: type: string example: 'Consignment tracking retrieved successfully' 404: description: '' content: application/json: schema: type: object example: success: false message: 'Consignment not found' properties: success: type: boolean example: false message: type: string example: 'Consignment not found' tags: - 'Consignment Management' security: [] parameters: - in: path name: id description: 'The ID or consignment number of the consignment.' example: 0 required: true schema: type: integer /api/consignments: get: summary: 'List all consignments' operationId: listAllConsignments description: "Get a list of all consignments. The results are filtered based on user role:\n- Admin/Manager users can see all consignments\n- Regular users can only see their own consignments" parameters: - in: query name: from_date description: 'Filter consignments created after this date.' example: '2024-03-01' required: false schema: type: string description: 'Filter consignments created after this date.' example: '2024-03-01' nullable: false - in: query name: to_date description: 'Filter consignments created before this date.' example: '2024-03-20' required: false schema: type: string description: 'Filter consignments created before this date.' example: '2024-03-20' nullable: false - in: query name: status description: 'Filter by consignment status (case-insensitive).' example: booked required: false schema: type: string description: 'Filter by consignment status (case-insensitive).' example: booked nullable: false responses: 200: description: '' content: application/json: schema: type: object example: success: true data: - id: 1 consignment_no: NYC-LAX-123456 status: id: 1 name: Booked consigner: name: 'John Doe' phone: '+1234567890' address: '123 Main St' consignee: name: 'Jane Smith' phone: '+1987654321' address: '456 Oak St' branch: id: 1 name: 'Main Branch' created_at: '2024-03-20T10:00:00.000000Z' properties: success: type: boolean example: true data: type: array example: - id: 1 consignment_no: NYC-LAX-123456 status: id: 1 name: Booked consigner: name: 'John Doe' phone: '+1234567890' address: '123 Main St' consignee: name: 'Jane Smith' phone: '+1987654321' address: '456 Oak St' branch: id: 1 name: 'Main Branch' created_at: '2024-03-20T10:00:00.000000Z' items: type: object properties: id: type: integer example: 1 consignment_no: type: string example: NYC-LAX-123456 status: type: object properties: id: type: integer example: 1 name: type: string example: Booked consigner: type: object properties: name: type: string example: 'John Doe' phone: type: string example: '+1234567890' address: type: string example: '123 Main St' consignee: type: object properties: name: type: string example: 'Jane Smith' phone: type: string example: '+1987654321' address: type: string example: '456 Oak St' branch: type: object properties: id: type: integer example: 1 name: type: string example: 'Main Branch' created_at: type: string example: '2024-03-20T10:00:00.000000Z' tags: - 'Consignment Management' security: [] '/api/consignment/{id}': get: summary: 'Get consignment details' operationId: getConsignmentDetails description: "Retrieve detailed information about a specific consignment. Can be accessed by ID or consignment number.\nRegular users can only access their own consignments." parameters: [] responses: 200: description: '' content: application/json: schema: type: object example: success: true data: id: 1 consignment_no: NYC-LAX-123456 status: id: 1 name: Booked consigner: name: 'John Doe' phone: '+1234567890' address: '123 Main St' cnic: 12345-6789012-3 consignee: name: 'Jane Smith' phone: '+1987654321' address: '456 Oak St' branch: id: 1 name: 'Main Branch' trackings: - id: 1 status: Booked created_at: '2024-03-20T10:00:00.000000Z' originCity: id: 1 name: 'New York' destinationCity: id: 2 name: 'Los Angeles' message: 'Consignment retrieved successfully' properties: success: type: boolean example: true data: type: object properties: id: type: integer example: 1 consignment_no: type: string example: NYC-LAX-123456 status: type: object properties: id: type: integer example: 1 name: type: string example: Booked consigner: type: object properties: name: type: string example: 'John Doe' phone: type: string example: '+1234567890' address: type: string example: '123 Main St' cnic: type: string example: 12345-6789012-3 consignee: type: object properties: name: type: string example: 'Jane Smith' phone: type: string example: '+1987654321' address: type: string example: '456 Oak St' branch: type: object properties: id: type: integer example: 1 name: type: string example: 'Main Branch' trackings: type: array example: - id: 1 status: Booked created_at: '2024-03-20T10:00:00.000000Z' items: type: object properties: id: type: integer example: 1 status: type: string example: Booked created_at: type: string example: '2024-03-20T10:00:00.000000Z' originCity: type: object properties: id: type: integer example: 1 name: type: string example: 'New York' destinationCity: type: object properties: id: type: integer example: 2 name: type: string example: 'Los Angeles' message: type: string example: 'Consignment retrieved successfully' 404: description: '' content: application/json: schema: type: object example: success: false message: 'Consignment not found' properties: success: type: boolean example: false message: type: string example: 'Consignment not found' tags: - 'Consignment Management' security: [] parameters: - in: path name: id description: 'The ID or consignment number of the consignment.' example: 0 required: true schema: type: integer /api/login: post: summary: '' operationId: postApiLogin description: '' parameters: [] responses: { } tags: - Endpoints security: [] /api/getDeliverySheets: get: summary: '' operationId: getApiGetDeliverySheets description: '' parameters: [] responses: 302: description: '' content: text/plain: schema: type: string example: "\n\n \n \n \n\n Redirecting to https://api.citycourier.org/public\n \n \n Redirecting to https://api.citycourier.org/public.\n \n" tags: - Endpoints security: [] /api/updateConsignment: post: summary: '' operationId: postApiUpdateConsignment description: '' parameters: [] responses: { } tags: - Endpoints requestBody: required: true content: application/json: schema: type: object properties: deliverysheet_id: type: string description: 'The id of an existing record in the deliverysheets table.' example: consequatur nullable: false consignment_id: type: string description: 'The id of an existing record in the consignments table.' example: consequatur nullable: false status_id: type: string description: '' example: consequatur nullable: false required: - deliverysheet_id - consignment_id - status_id security: []