Skip to main content

Overview

The Mensaje content type manages contact form submissions and communications from website visitors. It tracks messages, sender information, and response status.
This is a collection type with draft and publish enabled. Messages can be reviewed before being marked as handled.

Schema Information

  • Collection Name: mensajes
  • Singular: mensaje
  • Plural: mensajes
  • Draft & Publish: Enabled

Attributes

nombre

nombre
string
required
Name of the person sending the message.
  • Required field
  • Free text format
  • Used for addressing responses

email

email
email
required
Email address of the sender.
  • Required field
  • Email format validation
  • Used for sending responses

mensaje

mensaje
blocks
required
The message content.
  • Required field
  • Supports rich text blocks
  • Can include formatting, links, and structured content
  • Main communication from the sender

fecha

fecha
datetime
Timestamp when the message was sent.
  • Optional field
  • Datetime format: ISO 8601
  • Automatically set to submission time if not provided

respondido

respondido
boolean
default:false
Whether the message has been responded to.
  • Default: false
  • Used to track message handling status
  • Set to true after sending a response

API Endpoints

List All Messages

curl -X GET 'https://api.example.com/api/mensajes?sort=fecha:desc' \
  -H 'Authorization: Bearer YOUR_TOKEN'
data
array
Array of message entries

Get Single Message

curl -X GET 'https://api.example.com/api/mensajes/1' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Create Message

curl -X POST 'https://api.example.com/api/mensajes' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "data": {
      "nombre": "Pedro Silva",
      "email": "[email protected]",
      "mensaje": [
        {
          "type": "paragraph",
          "children": [
            {
              "type": "text",
              "text": "Hola, me gustaría obtener más información sobre las próximas competencias."
            }
          ]
        }
      ],
      "fecha": "2026-03-04T14:30:00.000Z",
      "respondido": false
    }
  }'

Mark as Responded

curl -X PUT 'https://api.example.com/api/mensajes/1' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
    "data": {
      "respondido": true
    }
  }'

Delete Message

curl -X DELETE 'https://api.example.com/api/mensajes/1' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Query Parameters

Filter Unresponded Messages

curl -X GET 'https://api.example.com/api/mensajes?filters[respondido][$eq]=false&sort=fecha:asc' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Filter Responded Messages

curl -X GET 'https://api.example.com/api/mensajes?filters[respondido][$eq]=true' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Filter by Date Range

# Messages from last 7 days
curl -X GET 'https://api.example.com/api/mensajes?filters[fecha][$gte]=2026-02-26T00:00:00Z&sort=fecha:desc' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Search by Sender Email

curl -X GET 'https://api.example.com/api/mensajes?filters[email][$contains]=example.com' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Sorting

# Newest first
curl -X GET 'https://api.example.com/api/mensajes?sort=fecha:desc' \
  -H 'Authorization: Bearer YOUR_TOKEN'

# Oldest unresponded first (priority queue)
curl -X GET 'https://api.example.com/api/mensajes?filters[respondido][$eq]=false&sort=fecha:asc' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Example Response

{
  "data": [
    {
      "id": 1,
      "attributes": {
        "nombre": "Pedro Silva",
        "email": "[email protected]",
        "mensaje": [
          {
            "type": "paragraph",
            "children": [
              {
                "type": "text",
                "text": "Hola, me gustaría obtener más información sobre las próximas competencias."
              }
            ]
          },
          {
            "type": "paragraph",
            "children": [
              {
                "type": "text",
                "text": "Específicamente sobre fechas y categorías disponibles."
              }
            ]
          }
        ],
        "fecha": "2026-03-04T14:30:00.000Z",
        "respondido": false,
        "createdAt": "2026-03-04T14:30:05.000Z",
        "updatedAt": "2026-03-04T14:30:05.000Z",
        "publishedAt": "2026-03-04T14:30:10.000Z"
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pageSize": 25,
      "pageCount": 1,
      "total": 1
    }
  }
}

Contact Form Integration

Frontend Implementation

import { useState } from 'react';

function ContactForm() {
  const [formData, setFormData] = useState({
    nombre: '',
    email: '',
    mensaje: ''
  });
  const [status, setStatus] = useState('idle');

  const handleSubmit = async (e) => {
    e.preventDefault();
    setStatus('submitting');

    try {
      const response = await fetch('https://api.example.com/api/mensajes', {
        method: 'POST',
        headers: {
          'Authorization': 'Bearer YOUR_TOKEN',
          'Content-Type': 'application/json'
        },
        body: JSON.stringify({
          data: {
            nombre: formData.nombre,
            email: formData.email,
            mensaje: [
              {
                type: 'paragraph',
                children: [
                  {
                    type: 'text',
                    text: formData.mensaje
                  }
                ]
              }
            ],
            fecha: new Date().toISOString(),
            respondido: false
          }
        })
      });

      if (response.ok) {
        setStatus('success');
        setFormData({ nombre: '', email: '', mensaje: '' });
      } else {
        setStatus('error');
      }
    } catch (error) {
      setStatus('error');
    }
  };

  return (
    <form onSubmit={handleSubmit}>
      <input
        type="text"
        placeholder="Nombre"
        value={formData.nombre}
        onChange={(e) => setFormData({ ...formData, nombre: e.target.value })}
        required
      />
      <input
        type="email"
        placeholder="Email"
        value={formData.email}
        onChange={(e) => setFormData({ ...formData, email: e.target.value })}
        required
      />
      <textarea
        placeholder="Mensaje"
        value={formData.mensaje}
        onChange={(e) => setFormData({ ...formData, mensaje: e.target.value })}
        required
      />
      <button type="submit" disabled={status === 'submitting'}>
        {status === 'submitting' ? 'Enviando...' : 'Enviar'}
      </button>
      {status === 'success' && <p>Mensaje enviado con éxito!</p>}
      {status === 'error' && <p>Error al enviar. Intente nuevamente.</p>}
    </form>
  );
}

Message Management Workflow

Best Practices

Auto-Timestamp

Automatically set the fecha field to the current timestamp when creating messages from contact forms.

Email Validation

Validate email format on both client and server side to ensure deliverability of responses.

Response SLA

Monitor unresponded messages and establish a service level agreement for response times (e.g., 24-48 hours).

Spam Prevention

Implement CAPTCHA or rate limiting on the contact form to prevent spam submissions.

Notification System

Set up email notifications to admins when new messages are received for prompt responses.

Message Archive

Periodically archive old responded messages to keep the active message list manageable.

Notifications and Alerts

Get Pending Message Count

curl -X GET 'https://api.example.com/api/mensajes?filters[respondido][$eq]=false&pagination[pageSize]=1' \
  -H 'Authorization: Bearer YOUR_TOKEN'

# Check meta.pagination.total for the count

Priority Messages (Older than 48 hours)

curl -X GET 'https://api.example.com/api/mensajes?filters[respondido][$eq]=false&filters[fecha][$lt]=2026-03-02T14:00:00Z&sort=fecha:asc' \
  -H 'Authorization: Bearer YOUR_TOKEN'

Email Response Template

When responding to messages, include:
  1. Greeting: Use the sender’s name from the nombre field
  2. Acknowledgment: Reference their original message
  3. Response: Provide the requested information or assistance
  4. Call to Action: Next steps or additional resources
  5. Signature: Club contact information
After sending a response email, always update the message record to set respondido: true for accurate tracking.

Message Statistics

Response Rate

Calculate your team’s response rate:
# Total messages
curl -X GET 'https://api.example.com/api/mensajes?pagination[pageSize]=1' \
  -H 'Authorization: Bearer YOUR_TOKEN'

# Responded messages
curl -X GET 'https://api.example.com/api/mensajes?filters[respondido][$eq]=true&pagination[pageSize]=1' \
  -H 'Authorization: Bearer YOUR_TOKEN'

# Response Rate = (Responded / Total) * 100

Rich Text Message Content

The mensaje field supports rich text blocks. Example structure:
[
  {
    "type": "paragraph",
    "children": [
      {
        "type": "text",
        "text": "Hola, tengo una consulta sobre "
      },
      {
        "type": "text",
        "text": "las inscripciones",
        "bold": true
      },
      {
        "type": "text",
        "text": "."
      }
    ]
  },
  {
    "type": "paragraph",
    "children": [
      {
        "type": "text",
        "text": "¿Cuándo cierran?"
      }
    ]
  }
]
While rich text is supported, most contact forms will submit plain text. The blocks structure ensures consistency with other content types.

Build docs developers (and LLMs) love