Overview
The Mensajes API allows you to manage contact form messages in the MTB Backend system. Each message includes sender information, content, submission date, and response status.
This endpoint supports draft and publish functionality. Use the publishedAt field to control publication status.
List All Mensajes
Retrieve a list of all contact messages with optional filtering, sorting, and pagination.
Query Parameters
Filter messages by field values. Example: filters[respondido][$eq]=false
Sort messages by field(s). Example: fecha:desc for newest first
Page number for pagination
Response
Array of mensaje objects Unique identifier for the message
Name of the message sender
Email address of the sender
Message content in blocks format
Date and time when the message was submitted
Whether the message has been responded to
Publication timestamp (null if draft)
Example Request
curl -X GET "https://api.example.com/api/mensajes?filters[respondido][ $eq ]=false&sort=fecha:desc" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN"
Example Response
{
"data" : [
{
"id" : 1 ,
"attributes" : {
"nombre" : "Pedro Martínez" ,
"email" : "[email protected] " ,
"mensaje" : [
{
"type" : "paragraph" ,
"children" : [
{ "type" : "text" , "text" : "Hola, quisiera información sobre las próximas competencias..." }
]
}
],
"fecha" : "2024-01-22T14:30:00.000Z" ,
"respondido" : false ,
"publishedAt" : "2024-01-22T14:30:00.000Z" ,
"createdAt" : "2024-01-22T14:30:00.000Z" ,
"updatedAt" : "2024-01-22T14:30:00.000Z"
}
}
],
"meta" : {
"pagination" : {
"page" : 1 ,
"pageSize" : 25 ,
"pageCount" : 1 ,
"total" : 1
}
}
}
Get a Single Mensaje
Retrieve a specific message by its ID.
Path Parameters
The unique identifier of the message
Response
The mensaje object (see List All Mensajes for structure)
Example Request
curl -X GET "https://api.example.com/api/mensajes/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN"
Example Response
{
"data" : {
"id" : 1 ,
"attributes" : {
"nombre" : "Pedro Martínez" ,
"email" : "[email protected] " ,
"mensaje" : [
{
"type" : "paragraph" ,
"children" : [
{ "type" : "text" , "text" : "Hola, quisiera información sobre las próximas competencias..." }
]
}
],
"fecha" : "2024-01-22T14:30:00.000Z" ,
"respondido" : false ,
"publishedAt" : "2024-01-22T14:30:00.000Z" ,
"createdAt" : "2024-01-22T14:30:00.000Z" ,
"updatedAt" : "2024-01-22T14:30:00.000Z"
}
}
}
Create a Mensaje
Create a new contact message. This is typically used by contact forms on the frontend.
Request Body
Name of the message sender
Email address of the sender
Message content in blocks format
Date and time of submission (auto-generated if not provided)
Whether the message has been responded to
Response
The created mensaje object
Example Request
curl -X POST "https://api.example.com/api/mensajes" \
-H "Content-Type: application/json" \
-d '{
"data": {
"nombre": "Sofía López",
"email": "[email protected] ",
"mensaje": [
{
"type": "paragraph",
"children": [{"type": "text", "text": "Me gustaría inscribirme en la próxima carrera. ¿Cuáles son los requisitos?"}]
}
],
"fecha": "2024-01-25T16:00:00.000Z"
}
}'
Example Response
{
"data" : {
"id" : 2 ,
"attributes" : {
"nombre" : "Sofía López" ,
"email" : "[email protected] " ,
"mensaje" : [
{
"type" : "paragraph" ,
"children" : [{ "type" : "text" , "text" : "Me gustaría inscribirme en la próxima carrera. ¿Cuáles son los requisitos?" }]
}
],
"fecha" : "2024-01-25T16:00:00.000Z" ,
"respondido" : false ,
"publishedAt" : null ,
"createdAt" : "2024-01-25T16:00:00.000Z" ,
"updatedAt" : "2024-01-25T16:00:00.000Z"
}
}
}
Update a Mensaje
Update an existing message by its ID. Commonly used to mark messages as responded.
Path Parameters
The unique identifier of the message to update
Request Body
Mensaje fields to update (same structure as Create)
Response
The updated mensaje object
Example Request
curl -X PUT "https://api.example.com/api/mensajes/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{
"data": {
"respondido": true
}
}'
Example Response
{
"data" : {
"id" : 1 ,
"attributes" : {
"nombre" : "Pedro Martínez" ,
"email" : "[email protected] " ,
"mensaje" : [ ... ],
"fecha" : "2024-01-22T14:30:00.000Z" ,
"respondido" : true ,
"publishedAt" : "2024-01-22T14:30:00.000Z" ,
"createdAt" : "2024-01-22T14:30:00.000Z" ,
"updatedAt" : "2024-01-25T17:00:00.000Z"
}
}
}
Delete a Mensaje
Delete a message by its ID.
Path Parameters
The unique identifier of the message to delete
Response
The deleted mensaje object
Example Request
curl -X DELETE "https://api.example.com/api/mensajes/1" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN"
Example Response
{
"data" : {
"id" : 1 ,
"attributes" : {
"nombre" : "Pedro Martínez" ,
"email" : "[email protected] " ,
"mensaje" : [ ... ],
"fecha" : "2024-01-22T14:30:00.000Z" ,
"respondido" : true ,
"publishedAt" : "2024-01-22T14:30:00.000Z" ,
"createdAt" : "2024-01-22T14:30:00.000Z" ,
"updatedAt" : "2024-01-25T17:00:00.000Z"
}
}
}
Important: Deleting a message is permanent and cannot be undone. Consider archiving messages instead of deleting them for record-keeping purposes.
Message Management Tips
Filtering Unresponded Messages
To get all messages that haven’t been responded to:
GET /api/mensajes?filters[respondido][ $eq ]= false & sort = fecha:asc
Marking Messages as Responded
After responding to a message via email or other means, update the message:
PUT / api / mensajes / : id
{
"data" : {
"respondido" : true
}
}
Date Filtering
To get messages from a specific date range:
GET /api/mensajes?filters[fecha][ $gte ]=2024-01-01 & filters[fecha][$lte] =2024-01-31