> ## Documentation Index
> Fetch the complete documentation index at: https://compass.docs.sunnyscoach.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Ticket Details

> Retrieves the full details of a single HubSpot ticket using its unique `ticketId`.   Requires authentication and a valid HubSpot ticket ID.
The endpoint validates the ticket ID before fetching data and returns complete ticket metadata including content, related contacts, categories, and assigned agent.


Retrieves the full details of a single HubSpot ticket using its unique ticketId. Requires authentication and a valid HubSpot ticket ID. The endpoint validates the ticket ID before fetching data and returns complete ticket metadata including content, related contacts, categories, and assigned agent.

## Request

### Headers

| Name          | Type   | Required | Description  |
| ------------- | ------ | -------- | ------------ |
| Authorization | string | Yes      | Bearer token |

### Path Parameters

| Parameter | Type   | Required | Description                      |
| --------- | ------ | -------- | -------------------------------- |
| ticketId  | string | Yes      | Unique HubSpot ticket identifier |

#### Parameter Details

* **ticketId**: Must be a valid HubSpot ticket ID
* **Format**: String identifier from HubSpot system
* **Validation**: Endpoint validates ticket ID before processing

## Response

### 200 OK - Successfully retrieved ticket details

```json theme={null}
{
  "message": "",
  "data": {
    "ticketId": "12345678",
    "subject": "Late Driver - Airport Pickup",
    "content": "Customer reported that driver was 45 minutes late for scheduled airport pickup. Passenger had to wait at arrivals and missed important meeting. Requesting refund for inconvenience.",
    "feedbackCategory": "Late Driver",
    "agentInvolved": "abdullah",
    "status": "closed",
    "priority": "high",
    "createdAt": "2025-10-01T10:30:00.000Z",
    "updatedAt": "2025-10-01T14:45:00.000Z",
    "closedAt": "2025-10-01T14:45:00.000Z",
    "departmentCode": "OPS",
    "passenger_name": "John Smith",
    "passenger_email": "john.smith@example.com",
    "passenger_phone": "+1-555-123-",
    "chauffeur_name": "Mike Johnson",
    "chauffeur_id": "CH78",
    "reservation_id": "RES",
    "pickup_location": "J",
    "dropoff_location": "o",
    "scheduled_time": "2025-10-01T09:00:00.000Z",
    "actual_time": "2025-10-01T09:45:00.000Z",
    "delay_minutes": 45,
    "resolution_notes": "Apology issued, partial refund processed, driver coached on punctuality",
    "tags": ["urgent", "airport", "refund"],
    "custom_properties": {
      "vehicle_type": "Luxury Sedan",
      "service_level": "Premium",
      "complaint_type": "delay"
    },
    "associated_contacts": [
      {
        "id": "contact-123",
        "name": "John Smith",
        "email": "john.smith@example.com",
        "type": "passenger"
      },
      {
        "id": "contact-123",
        "name": "Mike Johnson",
        "email": "mike.johnson@company.com",
        "type": "chauffeur"
      }
    ],
    "activity_log": [
      {
        "timestamp": "2025-10-01T10:30:00.000Z",
        "action": "created",
        "user": "system",
        "notes": "Ticket automatically created from feedback form"
      },
      {
        "timestamp": "2025-10-01T11:00:00.000Z",
        "action": "assigned",
        "user": "admin",
        "notes": "Assigned to agent abdullah"
      },
      {
        "timestamp": "2025-10-01T14:45:00.000Z",
        "action": "resolved",
        "user": "abdullah",
        "notes": "Issue resolved with customer satisfaction"
      }
    ]
  }
}
```

### 400 Bad Request

```json theme={null}
{
  "error": {
    "code": "INVALID_TICKET_ID",
    "message": "Invalid or missing ticket ID"
  }
}
```

### 404 Not Found

```json theme={null}
{
  "error": {
    "code": "TICKET_NOT_FOUND",
    "message": "Ticket not found"
  }
}
```

### 401 Unauthorized

```json theme={null}
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "Missing or invalid token"
  }
}
```

### 500 Internal Server Error

```json theme={null}
{
  "error": {
    "code": "SERVER_ERROR",
    "message": "Internal server error"
  }
}
```

## Example

```bash theme={null}
curl -X GET 'http://localhost:2000/hubspot/ticket-details/123456' \
  -H 'Authorization:Bearer your-jwt-token'
```

## Data Fields Explained

### Core Ticket Information

| Field            | Type   | Description                               |
| ---------------- | ------ | ----------------------------------------- |
| ticketId         | string | Unique HubSpot ticket identifier          |
| subject          | string | Ticket subject line                       |
| content          | string | Full ticket content/description           |
| feedbackCategory | string | Feedback category assigned to ticket      |
| agentInvolved    | string | Agent handling the ticket                 |
| status           | string | Current ticket status                     |
| priority         | string | Ticket priority level (low, medium, high) |

### Timestamps

| Field     | Type   | Description                          |
| --------- | ------ | ------------------------------------ |
| createdAt | string | Ticket creation timestamp (ISO 8601) |
| updatedAt | string | Last update timestamp (ISO 8601)     |
| closedAt  | string | Ticket closure timestamp (ISO 8601)  |

### Service Information

| Field             | Type    | Description                            |
| ----------------- | ------- | -------------------------------------- |
| departmentCode    | string  | Department code associated with ticket |
| reservation\_id   | string  | Associated reservation ID              |
| pickup\_location  | string  | Pickup location details                |
| dropoff\_location | string  | Dropoff location details               |
| scheduled\_time   | string  | Scheduled service time (ISO 8601)      |
| actual\_time      | string  | Actual service time (ISO 8601)         |
| delay\_minutes    | integer | Delay in minutes (if applicable)       |

### People Information

| Field            | Type   | Description             |
| ---------------- | ------ | ----------------------- |
| passenger\_name  | string | Passenger name          |
| passenger\_email | string | Passenger email address |
| passenger\_phone | string | Passenger phone number  |
| chauffeur\_name  | string | Chauffeur name          |
| chauffeur\_id    | string | Chauffeur ID            |

### Additional Information

| Field                | Type   | Description                   |
| -------------------- | ------ | ----------------------------- |
| resolution\_notes    | string | Notes about ticket resolution |
| tags                 | array  | Tags associated with ticket   |
| custom\_properties   | object | Custom HubSpot properties     |
| associated\_contacts | array  | Related contact information   |
| activity\_log        | array  | Ticket activity history       |

## Use Cases

* **Ticket Details View**: Display complete ticket information
* **Customer Service**: Provide detailed ticket history
* **Analytics**: Analyze ticket patterns and details
* **Reporting**: Generate detailed ticket reports
* **Audit Trail**: Track ticket activity and changes

## Implementation Examples

### React Ticket Detail Component

```jsx theme={null}
import React, { useState, useEffect } from 'react';

function TicketDetail({ ticketId }) {
  const [ticket, setTicket] = useState(null);
  const [loading, setLoading] = useState(true);
  const [error, setError] = useState(null);

  useEffect(() => {
    fetchTicketDetails();
  }, [ticketId]);

  const fetchTicketDetails = async () => {
    try {
      const response = await fetch(`/hubspot/ticket-details/${ticketId}`, {
        headers: { 'Authorization': `Bearer ${token}` }
      });
      
      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }
      
      const data = await response.json();
      setTicket(data.data);
    } catch (error) {
      setError(error.message);
    } finally {
      setLoading(false);
    }
  };

  if (loading) return <LoadingSpinner />;
  if (error) return <ErrorMessage error={error} />;
  if (!ticket) return <div>No ticket found</div>;

  return (
    <div className="ticket-detail">
      <TicketHeader ticket={ticket} />
      <TicketContent ticket={ticket} />
      <TicketActivity activity={ticket.activity_log} />
      <TicketContacts contacts={ticket.associated_contacts} />
    </div>
  );
}
```

### Activity Timeline Component

```jsx theme={null}
function ActivityTimeline({ activity }) {
  return (
    <div className="activity-timeline">
      <h3>Activity Log</h3>
      {activity.map((item, index) => (
        <div key={index} className="activity-item">
          <div className="activity-time">
            {new Date(item.timestamp).toLocaleString()}
          </div>
          <div className="activity-action">{item.action}</div>
          <div className="activity-user">{item.user}</div>
          <div className="activity-notes">{item.notes}</div>
        </div>
      ))}
    </div>
  );
}
```

### Ticket Status Badge

```jsx theme={null}
function TicketStatus({ status }) {
  const statusConfig = {
    'open': { color: 'orange', label: 'Open' },
    'closed': { color: 'green', label: 'Closed' },
    'pending': { color: 'blue', label: 'Pending' },
    'escalated': { color: 'red', label: 'Escalated' }
  };

  const config = statusConfig[status] || { color: 'gray', label: status };

  return (
    <span className={`status-badge status-${config.color}`}>
      {config.label}
    </span>
  );
}
```

## Best Practices

1. **Error Handling**: Handle ticket not found and invalid ID cases
2. **Loading States**: Show loading indicators while fetching details
3. **Data Validation**: Validate ticket ID format before API call
4. **Caching**: Cache ticket details for short periods
5. **Responsive Design**: Ensure detail view works on mobile devices

## Performance Considerations

* **Data Size**: Ticket details can be large with activity logs
* **API Calls**: Minimize unnecessary detail API calls
* **Images**: Handle any associated images efficiently
* **Real-time Updates**: Consider WebSocket for live updates

## Related Endpoints

* Use `/hubspot/tickets/list` to browse and find tickets
* Use `/hubspot/tickets/list/filters` for filter options
* Use `/hubspot/tickets/list/export` to export ticket data

## Notes

* Ticket details include all available HubSpot properties
* Activity log shows chronological ticket history
* Associated contacts include passengers, chauffeurs, and staff
* Custom properties vary based on HubSpot configuration
* Response time depends on ticket complexity and activity log size


## OpenAPI

````yaml GET /hubspot/ticket-details/{ticketId}
openapi: 3.0.3
info:
  title: COMPASS API
  version: 1.0.0
  description: OpenAPI specification for the Compass backend routes.
servers:
  - url: http://localhost:2000
    description: Local development server
security: []
tags:
  - name: Auth
    description: >-
      Authentication and session management endpoints (OAuth and session
      validation)
  - name: Users
    description: Operations for managing user records
  - name: Departments
    description: Operations for managing departments
  - name: Email Meter
    description: APIs to get Email Meter Stats
  - name: HubSpot Tickets
    description: Feedback APIs
  - name: Permissions
    description: Permissions APIs
  - name: Transcription
    description: Transcription APIs
paths:
  /hubspot/ticket-details/{ticketId}:
    get:
      tags:
        - HubSpot Tickets
      summary: Get detailed information of a specific HubSpot ticket
      description: >
        Retrieves the full details of a single HubSpot ticket using its unique
        `ticketId`.   Requires authentication and a valid HubSpot ticket ID.

        The endpoint validates the ticket ID before fetching data and returns
        complete ticket metadata including content, related contacts,
        categories, and assigned agent.
      parameters:
        - name: ticketId
          in: path
          required: true
          schema:
            type: string
          description: Unique HubSpot Ticket ID
          example: '123456789'
      responses:
        '200':
          description: Successfully retrieved ticket details
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
                    example: ''
                  data:
                    type: object
                    description: HubSpot ticket details
                    properties:
                      id:
                        type: string
                        example: '123456789'
        '400':
          description: Invalid or missing ticket ID
        '401':
          description: Unauthorized (missing or invalid token)
        '404':
          description: Ticket not found
        '500':
          description: Server error
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````