Common Flow Example
This example walks through a complete workflow that you’ll use frequently when integrating with the Gleap API.Step 1: Create or Find a Session
First, create a session to represent a user or contact. If a session with the sameuserId already exists, you can use that session ID instead.
Endpoint: POST /v3/sessions
Request:
Save the
_id or id from the response - you’ll need it to create a ticket linked to this session.Step 2: Create a Ticket
Now create a ticket and link it to the session you just created. The ticket represents a support request, bug report, or feature request. Endpoint:POST /v3/tickets
Request:
Save the
_id or id from the ticket response - you’ll need it to add comments to this ticket.Step 3: Create a Comment
Add a comment to the ticket. Comments can be simple text or rich formatted content. You can also attach files. Endpoint:POST /v3/messages
Request (Simple Text Comment):
Step 4: Create a Comment from Markdown
Instead of building the rich-text JSON structure yourself, you can send Markdown via themarkdownComment field. The server converts it to rich text automatically, and it takes precedence over comment if both are set.
Endpoint: POST /v3/messages
Request:
Messages created through this endpoint are always attributed to the user that owns the API key. It is not possible to create a comment on behalf of a customer (session) via this endpoint.