Ayra AI
|Docs

Update Ticket

Update an existing ticket

Updates an existing ticket. Only specified fields are modified; omitted fields remain unchanged.

Endpoint

PUT https://api.ayra.ai/v1/tickets/{ticket_id}

Authentication

Requires API key with tickets:write permission.

Path Parameters

ticket_id(string, required) - The unique identifier of the ticket

Request Parameters

All parameters are optional. Only include fields you want to update.

subject(string) - Ticket subject
description(string) - Ticket description
priority(integer) - Priority level (1-4)
status(string) - Ticket status
category(string) - Issue category
assigned_to(string) - User ID for assignment
due_date(string) - ISO 8601 due date
tags(array of strings) - Replace all tags
custom_fields(object) - Update custom fields (merged with existing)
internal_note(string) - Add internal note (not visible to customer)

Request Example

curl -X PUT https://api.ayra.ai/v1/tickets/ticket_abc123xyz789 \
  -H "Authorization: Bearer sk_live_abc123xyz789" \
  -H "Content-Type: application/json" \
  -d '{
    "status": "in_progress",
    "assigned_to": "user_jane_smith",
    "internal_note": "Contacted customer to verify refund amount."
  }'

JavaScript Example

async function updateTicket(ticketId, updates) {
  try {
    const response = await axios.put(
      `https://api.ayra.ai/v1/tickets/${ticketId}`,
      updates,
      {
        headers: {
          'Authorization': 'Bearer sk_live_abc123xyz789',
          'Content-Type': 'application/json'
        }
      }
    );
    
    console.log('Ticket updated:', ticketId);
    return response.data;
  } catch (error) {
    console.error('Error updating ticket:', error.response.data);
    throw error;
  }
}

// Example: Progress ticket through workflow
await updateTicket('ticket_abc123', {
  status: 'resolved',
  internal_note: 'Refund processed successfully.'
});

Python Example

def update_ticket(ticket_id, **updates):
    url = f'https://api.ayra.ai/v1/tickets/{ticket_id}'
    headers = {
        'Authorization': 'Bearer sk_live_abc123xyz789',
        'Content-Type': 'application/json'
    }
    
    response = requests.put(url, json=updates, headers=headers)
    
    if response.status_code == 200:
        ticket = response.json()
        print(f"Ticket updated: {ticket_id}")
        return ticket
    else:
        print('Error:', response.json())
        raise Exception(f'Failed to update ticket: {response.status_code}')

# Example: Escalate ticket
update_ticket(
    'ticket_abc123',
    priority=1,
    status='open',
    assigned_to='user_manager',
    internal_note='ESCALATED: Customer threatening legal action'
)

Notes

  • Updates create history entries tracking all changes
  • Changing status to 'resolved' sets resolved_at timestamp
  • Changing status to 'closed' sets closed_at timestamp
  • SLA metrics are recalculated when status changes
  • Internal notes are not visible to customers through public interfaces

Ready to transform your agency?

Start building with Ayra today. No credit card required.