Skip to content

Create Messages

Create Messages for a Ticket

This endpoint allows creating a message for a specific ticket, with or without attachments.

Required Scope | Field | Type | Description | Required | |----------------|--------|--------------------------------------|----------| | ticket_uuid | string | Unique identifier for the ticket. | Yes |

Request parameters

Field Type Description Required
code String Field for free use by the seller's system. Yes
message String Message to be sent. Yes
owner Object Responsible for sending the message. Yes
owner.code String Identifier in the external system (seller's ERP) for the author of the response. Yes
owner.name String Name of the author responsible for the response. Yes
destination String Recipient type. Yes
attachments List List of attachments to be sent. No
attachments.file_name String File name. Yes, if there are attachments to be sent.
attachments.file_extension String File extension. Yes, if there are attachments to be sent.
attachments.file_type String MIME type of the file. Yes, if there are attachments to be sent.

URL Parameters

Field Type Description Required
ticket_uuid string Unique identifier for the ticket. Yes

Request parameters

Field Type Description Required
code String Field for free use by the seller's system. Yes
message String Message to be sent. Yes
owner Object Responsible for sending the message. Yes
owner.code String Identifier in the external system (seller's ERP) for the author of the response. Yes
owner.name String Name of the author responsible for the response. Yes
destination String Recipient type. Yes
attachments List List of attachments to be sent. No
attachments.file_name String File name. Yes, if there are attachments to be sent.
attachments.file_extension String File extension. Yes, if there are attachments to be sent.
attachments.file_type String MIME type of the file. Yes, if there are attachments to be sent.

Attachment Restrictions - file_type: image/png, image/jpe, image/jpeg, image/jpg, image/gif, image/vnd.ms-photo, image/pdf, application/pdf - file_size: 5MB


Request:

curl -X 'POST' \
  'https://api.magalu.com/seller/v0/tickets/{ticket_uuid}/messages'
  -H 'accept: application/json' \
  -H 'Authorization: Bearer <Access Token>' \
  -H 'Content-Type: application/json' \ -d '{
    "code": "optional_user_defined_code",
    "message": "The product will be delivered next week.",
    "owner": {
      "code": "j.doe",
      "name": "John Doe"
    },
    "destination": "customer",
    "attachments": [
      {
        "file_name": "file_name_1.png",
        "file_extension": "png",
        "file_type": "image/png",
      },
      {
        "file_name": "file_name_2.png",
        "file_extension": "png",
        "file_type": "image/png",
      },
    ],
  }'

NOTE: For sending attachments in this flow, this initial request only informs the names and extensions of the files the user wishes to send. In response, signed links will be provided to complete the upload of these files.

Response:

{
  "transaction_id": "e55e7339-3cf6-4fa0-883c-e9c3e38602ec",
  "data": {
    "message": "Exemplo",
    "code": "optional_user_defined_code",
    "ticket": {
      "id": "e1faf69b-336a-5415-8c33-fc63f505b766",
      "code": "4c503588-2a90-4ee4-b84b-b89d5a554f3e",
      "type": "cancellation"
    },
    "destination": "customer",
    "attachments": [
      {
        "id": "71b25f3a-0ae2-484f-868e-418b0c1d5991",
        "file_name": "71b25f3a-0ae2-484f-868e-418b0c1d5991.png",
        "provided_file_name": "file_name.png",
        "file_extension": "png",
        "file_type": "image/png",
        "file_path": "e55e7339-3cf6-4fa0-883c-e9c3e38602ec/71b25f3a-0ae2-484f-868e-418b0c1d5991.png",
        "signed_link": {
          "url": "https://storage.googleapis.com/sac-attachments-tmp-staging/e55e7339-3cf6-4fa0-883c-e9c3e38602ec/71b25f3a-0ae2-484f-868e-418b0c1d5991.png?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=ps-core-customer-service%40maga-homolog.iam.gserviceaccount.com%2F20241108%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20241108T131525Z&X-Goog-Expires=3600&X-Goog-SignedHeaders=content-type%3Bhost%3Bx-goog-content-length-range&X-Goog-Signature=...",
          "method": "PUT",
          "expires_at": "2024-11-08T14:15:25.416590",
          "max_size": 5242880,
          "expired": false,
          "headers": {
            "Content-Length": "5242880",
            "x-goog-content-length-range": "0,5242880"
          }
        }
      }
    ],
    "created_by": "17aa4169-0aee-4417-9739-d86748b330b0"
  },
  "links": [
    {
      "path": "/seller/v0/transactions/e55e7339-3cf6-4fa0-883c-e9c3e38602ec"
    }
  ]
}

Complete Attachment Upload

If the message includes attachments, it is necessary to upload the files to the signed URLs returned in the response payload using the headers also provided in the payload. The message creation process will be paused until the attachments are successfully uploaded.

Below is an example request for uploading a file to a signed URL:

curl -X PUT   'https://storage.googleapis.com...'   -H 'Content-Length: 5242880'   -H 'x-goog-content-length-range: 0,5242880'   --data-binary '@path/to/file_name_1.png'

When all attachments are successfully uploaded to their respective signed URLs, the message creation flow will resume.

NOTES:

- If the file upload is not completed within 15 minutes of the initial request, the message will expire and will not be created.

- If more than one attachment is sent to a signed link, there may be inconsistencies in the relationship between the attachment and the message.

Return Codes

Code Description
202 Accepted
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error

Track Message Creation Completion

Message creation is now an asynchronous process and can be tracked via transactions. See the documentation on asynchronous responses and transactions for more information on this process.