Tickets
Handle data related to ImBox Tickets.
Create ticket
Create a ticket with its first message. To add a message to an existing ticket, use Update ticket.
Note: When creating tickets with this API Mail Flow will be bypassed. This means for example any automatic labeling setup in Mail Flow will not apply on these tickets. Please define desired actions directly in the request.
Parameters
| Name | Type | Description |
|---|---|---|
| apiKey* | String | Your API key |
Body
| Name | Type | Description |
|---|---|---|
| mailbox* | String | Email address of the mailbox the ticket belongs to. Ex. "info@your-company.com" |
| requester* | { address: String, name: String } | The customer the ticket is about. name is optional. |
| subject* | String | Ticket subject |
| content* | Content | The first message of the ticket |
| status | String | "new" | "reply" | "pending" | "solved" | "closed" | "on-hold". Default: "new" |
| priority | String | "low" | "normal" | "high" | "urgent". Default: "normal" |
| addLabels | Array<String> | Label names to add to the ticket. The labels must exist. Not case sensitive. |
| addAgents | Array<String | Number> | Email addresses or ids of ImBox agents to assign to the ticket. Either all email addresses or all ids. The agents must have access to the mailbox. |
| autoReply | Boolean | Send the mailbox's auto reply to the requester, if auto replies are activated on the mailbox. Default: true |
The auto reply is only sent for an external message that isn't written by an agent, and never when the requester is the mailbox itself.
Content
The message in content.
| Name | Type | Description |
|---|---|---|
| message* | String | Message text |
| from* | { address: String, name: String } | { agentId: Number } | The sender, by email address or agent id. name is optional. |
| type | String | "external" | "internal". "internal" creates a private note in the ticket. Default: "external" |
| subject | String | Subject of the message and its email. Default: the ticket's subject |
| to | Array<{ address: String, name: String }> | Recipients |
| cc | Array<{ address: String, name: String }> | Recipients |
| bcc | Array<{ address: String, name: String }> | Recipients |
| attachments | Array<String> | URLs of files to attach. Total file size limit of 50 MB. Ex: ["https://yourfile.com", "https://yourfile2.com"] |
| sendEmail | Boolean | Send the message as an email to to, cc and bcc. Only for messages from agents. Default: false |
Messages from agents
When from.agentId is given, or from.address belongs to one of your ImBox agents, the message is written by that agent and is stored with the agent's name. from.name is ignored. An agentId must be the id of one of your agents.
With sendEmail, the email is sent from the mailbox's sender name and address, only to the given to, cc and bcc. The requester isn't added automatically. Without sendEmail, the message is only added to the ticket.
Messages from others
An external message from someone who isn't an agent, for example the requester, must include the mailbox in to, cc or bcc, and can't be sent as an email.
Internal notes
An internal note is a private note in the ticket. Anyone can write one, and it can't have recipients or be sent as an email.
Rules
| Rule | Message |
|---|---|
An external message needs at least one of to, cc or bcc | to, cc or bcc is required for external content |
from can't also be a recipient | from address cannot be included in to, cc or bcc |
| A message from someone who isn't an agent must include the mailbox | mailbox <mailbox> must be in to, cc or bcc when the sender isn't an agent |
| An email can't be sent to the mailbox | content cannot be emailed when the mailbox is in to, cc or bcc |
| An internal note can't have recipients | internal content cannot have to, cc or bcc |
| An internal note can't be sent as an email | internal content cannot be emailed |
A message can have at most 50 recipients in to, cc and bcc together | to, cc and bcc cannot have more than 50 recipients in total |
from needs exactly one of address and agentId | from needs either address or agentId |
from.agentId must be one of your agents | unknown agent: <id> |
Attachments
Every attachment URL must be downloadable. Compressed files are decompressed, and the 50 MB limit applies to the decompressed size. If one can't be fetched, or the files are too large, nothing is created and the request fails with one of these messages:
failed to fetch attachment <url>failed to fetch attachment <url>, status code: <code>attachments exceeds file size limit of 50 MBAttachment too largeunsupported content encoding <coding> for attachment <url>
Usage
curl -X POST -H "Content-Type: application/json" -d @ticket.json "https://apiv2.imbox.io/:apiKey/tickets"
ticket.json
{
"mailbox": "info@your-company.com",
"requester": { "address": "john.doe@example.com", "name": "John Doe" },
"subject": "My booking",
"content": {
"message": "Hello, I have a question about my booking.",
"from": { "address": "john.doe@example.com", "name": "John Doe" },
"to": [{ "address": "info@your-company.com" }]
},
"addLabels": ["Booking"] // optional
}
Response
201 Created
{
"ticketId": 1234,
"contentId": 5678
}
400 Bad Request
For invalid fields, the message lists each problem on its own line, followed by the path of the field.
{
"code": "BadRequest",
"message": "✖ Invalid email address\n → at requester.address\n✖ to, cc or bcc is required for external content\n → at content.to"
}
Other messages:
mailbox not found: no mailbox with the address inmailbox.unknown labels: <labels>: the labels don't exist.unknown agents: <emails and ids>: the agents don't exist or don't have access to the mailbox.- The content and attachment messages listed under Content.
403 Forbidden
{
"code": "NotAuthorized",
"message": "Not Authorized"
}
API key scope access
Configure API key access in ImBox Admin dashboard.
| Scope | Access |
|---|---|
| Tickets | Write |
Update ticket
Update a ticket, and optionally add a message to it. A message from an agent can be sent as an email.
Parameters
| Name | Type | Description |
|---|---|---|
| apiKey* | String | Your API key |
| ticketId* | Integer | Id of ticket |
Body
At least one field is required.
| Name | Type | Description |
|---|---|---|
| subject | String | Renames the ticket |
| status | String | "new" | "reply" | "pending" | "solved" | "closed" | "on-hold" |
| priority | String | "low" | "normal" | "high" | "urgent" |
| addLabels | Array<String> | Label names to add to the ticket. Existing labels are kept. The labels must exist. Not case sensitive. |
| addAgents | Array<String | Number> | Email addresses or ids of ImBox agents to assign to the ticket. Either all email addresses or all ids. Assigned agents are kept. The agents need access to the mailbox. |
| content | Content | A message to add to the ticket |
Adding content doesn't change the status. Send status to change it, for example to "reply" after a message from the requester.
subject renames the ticket. To set the subject of a message and its email, use content.subject.
Usage
curl -X PUT -H "Content-Type: application/json" -d @update.json "https://apiv2.imbox.io/:apiKey/tickets/:ticketId"
update.json
A reply from an agent, given by id, sent as an email to the requester. The ticket waits for the requester:
{
"status": "pending",
"content": {
"message": "Thank you, your booking is confirmed.",
"from": { "agentId": 1 },
"to": [{ "address": "john.doe@example.com" }],
"sendEmail": true
}
}
A change of status and labels, without a message:
{
"status": "solved",
"addLabels": ["Booking"]
}
Response
200 OK
{
"ticketId": 1234,
"contentId": 5678 // only when content was added
}
400 Bad Request
{
"code": "BadRequest",
"message": "✖ at least one field to update is required"
}
The other messages are the same as for Create ticket, except mailbox not found.
403 Forbidden
{
"code": "NotAuthorized",
"message": "Not Authorized"
}
404 Not Found
The ticket doesn't exist or is in the trash.
{
"code": "NotFound",
"message": "ticket not found"
}
API key scope access
Configure API key access in ImBox Admin dashboard.
| Scope | Access |
|---|---|
| Tickets | Write |
listTickets
Get tickets within a given timespan. If more than limit tickets exist, the next result set can be fetched using the href in ”next”.
Parameters
| Name | Type | Description |
|---|---|---|
| apiKey* | String | Your API key |
| userId* | String | Unique id for the user |
Query parameters
| Name | Type | Description |
|---|---|---|
| limit | Integer | Number of tickets to return |
| updatedAfter | Date string | returns items where updatedDate >= updatedAfter |
| updatedBefore | Date string | returns items where updatedDate <= updatedBefore |
| latestUpdatedAfter | Date string | returns items where latestUpdatedDate >= latestUpdatedAfter |
| latestUpdatedBefore | Date string | returns items where latestUpdatedDate <= latestUpdatedBefore |
| fromEmail | String | Email address |
| status | String | ”new” | ”reply” | ”pending” | ”solved” | ”closed” | ”on-hold” |
| fileType | String | Response type. ”csv” | ”json”. Default: ”json” |
| cursorId | Integer | Cursor for next result set |
| cursorUpdated | Integer | Cursor for next result set |
| label | String | Filter tickets by label. Can be repeated: &label=a&label=b returns tickets matching any of the specified labels |
updatedDateis an automatic timestamp updated anytime the database row changes.latestUpdatedDateis updated when actions happen to the ticket, like a change in status or an assignment of an agent.
Usage
curl -X GET "https://apiv2.imbox.io/message/listTickets/:apiKey/:userId?updatedAfter=2020-01-01&limit=2"
Response
{
"result": "success",
"json": [
{
"sid": 1,
"inboxName": "Support",
"ticketID": 1,
"status": "pending",
"subject": "Re: Booking",
"fromEmail": "john.doe@example.org",
"labels": ["label1", "label2"],
"createdDate": "2020-01-01T00:00:00.000Z",
"updatedDate": "2020-01-01T00:00:00.000Z",
"latestUpdated": "2020-01-01T00:00:00.000Z"
},
{
"sid": 1,
"inboxName": "Info",
"ticketID": 2,
"status": "new",
"subject": "My booking",
"fromEmail": "john.doe@example.org",
"labels": [],
"createdDate": "2020-01-01T00:00:00.000Z",
"updatedDate": "2020-01-01T00:00:00.000Z",
"latestUpdated": "2020-01-01T00:00:00.000Z"
}
],
"length": 2,
"next": "https://apiv2.imbox.io/message/listTickets/apiKey/userId?updatedAfter=2020-01-01&limit=2&cursorId=2&cursorUpdated=1686819359320"
}
API key scope access
Configure API key access in ImBox Admin dashboard.
| Scope | Access |
|---|---|
| Tickets | Read |
grabTicket
Get a ticket.
Parameters
| Name | Type | Description |
|---|---|---|
| apiKey* | String | Your API key |
| userId* | String | Unique id for the user |
| ticketId* | String | Id for ticket |
Usage
curl -X GET "https://apiv2.imbox.io/message/grabTicket/:apiKey/:userId/:ticketId"
Response
{
"result": "success",
"json": [
{
"sid": 1,
"ticketID": "1",
"from": "john.doe@example.org",
"fromName": "John",
"agentID": 1, // Null if not sent by agent
"messageType": "external", // External / Internal / Log
"messagePlain": "Hello", // Plain text content
"messageHtml": "<p>Hello</p>", // Raw HTML content
"attachments": ["https://example.com/image.png"], // URLs to attachments
"date": "2020-01-01T00:00:00.000Z" // Sent time
}
],
"length": 1,
"meta": {
"tags": [{ "tag": "tag name" }],
"labels": [{ "label": "label name" }],
"notes": "notes content",
"linkedTickets": [{ "ticketId": 123 }],
"ticketStatus": "pending",
"assignedAgents": [
{
"id": 7878,
"agentName": "Agent1 Name",
"agentEmail": "agent1@company.com"
},
{
"id": 7979,
"agentName": "Agent2 Name",
"agentEmail": "agent2@company.com"
}
],
"customFields": [
{
"title": "Order number",
"value": "12345",
"type": "text" // text / number / date / boolean / single-select / datetime / url / email / phone / swedish-personal-number
}
]
}
}
API key scope access
Configure API key access in ImBox Admin dashboard.
| Scope | Access |
|---|---|
| Tickets | Read |
insertTicket
insertTicket is deprecated. Use Create ticket to create tickets and Update ticket to add messages to existing tickets. The new endpoints use different field names, and fields they don't recognize are ignored:
toEmail→mailboxfromEmailandfromName→requesterandcontent.frommessage→content.messagemessageType→content.typeattachments→content.attachmentslabels→addLabelsassignAgents→addAgentsticketIdandappendOpenTicket→ use Update ticket
Create a ticket.
Note: When creating tickets with the insertTicket API Mail Flow will be bypassed. This means for example any automatic labeling setup in Mail Flow will not apply on these tickets. Please define desired actions directly in the request.
Parameters
| Name | Type | Description |
|---|---|---|
| apiKey* | String | Your API key |
| userId* | String | Unique id for the user |
Body
| Name | Type | Description |
|---|---|---|
| fromEmail* | String | Ex. "john.doe@example.org" |
| fromName | String | Ex. "John" |
| message* | String | Ticket content |
| subject* | String | Ticket subject |
| toEmail* | String | Email connected to your ImBox account. "info@your-company.com" |
| appendOpenTicket | Boolean | Append to already open ticket from same sender? Default: true |
| attachments | Array<String> | Adding uploaded files to ticket. Total file size limit of 50 MB. Ex: ["https://yourfile.com", "https://yourfile2.com"] |
| assignAgents | Array<String> | Email addresses for ImBox agents that will be assigned to the ticket. The agents need access to the mailbox for assign to be possible. |
| autoReply | Boolean | Send auto reply to "fromEmail" (if auto replies are activated on your ticket mailbox). Default: true |
| labels | Array<String> | Adding label names on Ticket. Ex. "Support" |
| messageType | String | "internal" | "external". "internal" means a private note will be created in the ticket. Default: "external". |
| status | String | "new" | "reply" | "pending" | "solved" | "closed" | "on-hold" |
| ticketId | String | Append message to a specific ticket (ticket cannot be deleted) |
Usage
curl -X POST -H "Content-Type: application/json" -d @ticket.json "https://apiv2.imbox.io/message/insertTicket/<apiKey>/<userId"
ticket.json
{
"fromEmail": "john.doe@example.com",
"toEmail": "info@your-company.se",
"subject": "My subject",
"message": "My message"
}
Response
{
"result": "success",
"json": {
"ticketID": 1234
}
}
API key scope access
Configure API key access in ImBox Admin dashboard.
| Scope | Access |
|---|---|
| Tickets | Write |
listTicketsEmails
Lists all email addresses for sent and received mails within a timespan. If more than limit emails exist, the next result set can be fetched using the href in ”next”.
Parameters
| Name | Type | Description |
|---|---|---|
| apiKey* | String | Your API key |
| userId* | String | Unique id for the user |
Query parameters
| Name | Type | Description |
|---|---|---|
| limit | Integer | Number of emails to return |
| startTime* | Date string | |
| endTime* | Date string | |
| timezone | String | Time zone. Default: Europe/Stockholm |
| fileType | String | Response type. ”csv” | ”json”. Default: ”json” |
| cursorId | Integer | Cursor for next result set |
| cursorCreated | Integer | Cursor for next result set |
Usage
curl -X GET "https://apiv2.imbox.io/message/listTicketsEmails/:apiKey/:userId?startTime=2020-01-01&endTime=2020-01-02&limit=2"
Response
{
"result": "success",
"json": [
{
"createdDate": "2020-01-01T00:00:00.000Z",
"inboxName": "Company Support",
"from": { "address": "agent@example.org", "name": "agent" },
"ticketID": 1,
"to": [{ "address": "customer@example.org" }],
"cc": [],
"bcc": []
},
{
"createdDate": "2020-01-01T00:00:00.000Z",
"inboxName": "Company Support",
"from": { "address": "agent2@example.org", "name": "Agent 2" },
"ticketID": 2,
"to": [{ "address": "another-customer@example.org" }],
"cc": [{ "address": "ccd@example.org" }],
"bcc": []
}
],
"next": "https://apiv2.imbox.io/message/listTicketsEmails/apiKey/userId?startTime=2020-01-01&endTime=2020-01-02&limit=2&cursorId=1234&cursorCreated=1577836800000",
"length": 2
}
API key scope access
Configure API key access in ImBox Admin dashboard.
| Scope | Access |
|---|---|
| Tickets | Read |