Close Ticket
Close a ticket marking it resolved
Closes a ticket, marking it as resolved and complete.
Endpoint
PUT https://api.ayra.ai/v1/tickets/{ticket_id}/closeAuthentication
Requires API key with tickets:write permission.
Path Parameters
ticket_id(string, required) - The unique identifier of the ticketRequest Parameters
Optional Parameters:
resolution_note(string) - Final resolution details. Maximum 5,000 characters.customer_satisfaction(integer) - Customer satisfaction rating, 1-10.resolution_time(integer) - Actual time spent resolving in minutes.root_cause(string) - Root cause category for analytics.Request Example
curl -X PUT https://api.ayra.ai/v1/tickets/ticket_abc123xyz789/close \
-H "Authorization: Bearer sk_live_abc123xyz789" \
-H "Content-Type: application/json" \
-d '{
"resolution_note": "Refund of $99.99 processed successfully...",
"customer_satisfaction": 9,
"root_cause": "system_error"
}'JavaScript Example
async function closeTicket(ticketId, resolutionDetails) {
try {
const response = await axios.put(
`https://api.ayra.ai/v1/tickets/${ticketId}/close`,
resolutionDetails,
{
headers: {
'Authorization': 'Bearer sk_live_abc123xyz789',
'Content-Type': 'application/json'
}
}
);
console.log('Ticket closed:', ticketId);
return response.data;
} catch (error) {
console.error('Error closing ticket:', error.response.data);
throw error;
}
}
// Example: Close ticket with details
closeTicket('ticket_abc123xyz789', {
resolution_note: 'Issue resolved. Customer satisfied.',
customer_satisfaction: 9,
root_cause: 'user_error'
});Python Example
def close_ticket(ticket_id, resolution_note, customer_satisfaction=None, root_cause=None):
url = f'https://api.ayra.ai/v1/tickets/{ticket_id}/close'
headers = {
'Authorization': 'Bearer sk_live_abc123xyz789',
'Content-Type': 'application/json'
}
data = {
'resolution_note': resolution_note
}
if customer_satisfaction:
data['customer_satisfaction'] = customer_satisfaction
if root_cause:
data['root_cause'] = root_cause
response = requests.put(url, json=data, headers=headers)
if response.status_code == 200:
ticket = response.json()
print(f"Ticket {ticket_id} closed successfully")
return ticket
else:
print('Error:', response.json())
raise Exception(f'Failed to close ticket: {response.status_code}')
# Example usage
close_ticket(
'ticket_abc123xyz789',
resolution_note='Refund processed. Customer confirmed satisfaction.',
customer_satisfaction=10,
root_cause='billing_error'
)Response
Success Response (200 OK):
{
"data": {
"id": "ticket_abc123xyz789",
"number": "TICK-1234",
"status": "closed",
"resolution_note": "Refund of $99.99 processed successfully...",
"customer_satisfaction": 9,
"root_cause": "system_error",
"sla": {
"response_met": true,
"resolution_met": true
},
"resolved_at": "2025-01-15T16:30:00Z",
"closed_at": "2025-01-15T16:30:00Z"
}
}Error Responses
404 Not Found:
{
"error": {
"type": "not_found",
"message": "Ticket not found",
"code": "ticket_not_found"
}
}409 Conflict - Already Closed:
{
"error": {
"type": "conflict",
"message": "Ticket is already closed",
"code": "ticket_already_closed",
"closed_at": "2025-01-15T16:30:00Z"
}
}Notes
- •Closing sets both
resolved_atandclosed_atto current timestamp - •SLA metrics are finalized when ticket closes
- •Closed tickets can be reopened if issues recur
- •Resolution notes are visible to customers in support portals
- •Customer satisfaction scores feed into support analytics and agent performance metrics
Ready to transform your agency?
Start building with Ayra today. No credit card required.