API Documentation
Create Magazine Post - Complete Reference
Version: 1.0 | Last updated: January 8, 2026
Endpoint
POST
/api/magazines/create.php
This endpoint allows authenticated users to create and publish new magazine posts on the PrimePages platform. All magazines are published immediately upon successful creation.
Authentication
Two levels of authentication are required to use this endpoint:
1. API Key
Provide your API key using either method:
- Query Parameter:
?api_key=m9xK8vQ2pL5nR7gfggertrsfssdg - Header:
X-API-Key: m9xK8vQ2pL5nR7gfggertrsfssdg
2. User Token
Provide your user token (obtained from login) using either method:
- Query Parameter:
?token=65a4f8b3c2d1e9f7a6b5c4d3e2f1a0b9c8d7e6f5 - Header (Bearer):
Authorization: Bearer 65a4f8b3c2d1e9f7a6b5c4d3e2f1a0b9c8d7e6f5
Headers
Content-Type: application/json
X-API-Key: m9xK8vQ2pL5nR7gfggertrsfssdg
Authorization: Bearer {user_token}
Request Parameters (Body - JSON)
| Parameter | Type | Required | Description |
|---|---|---|---|
title | string | ✅ Required | Title of the magazine |
category_id | integer | ✅ Required | ID of the category (must exist in database) |
language | string | ✅ Required | Language code (ej: "es", "en", "fr") |
pdf_file | string | ✅ Required | URL or path to the PDF file |
description | string | ❌ Optional | Magazine description |
pages | integer | ❌ Optional | Number of pages (default: 0) |
cover_image | string | ❌ Optional | Cover image URL (default: "default-cover.jpg") |
issue_date | string | ❌ Optional | Issue date in YYYY-MM-DD format (default: current date) |
Example Request
cURL
curl -X POST "https://primepages.sbs/api/magazines/create.php?api_key=m9xK8vQ2pL5nR7gfggertrsfssdg&token=65a4f8b3c2d1e9f7a6b5c4d3e2f1a0b9c8d7e6f5" \
-H "Content-Type: application/json" \
-d '{
"title": "National Geographic - Enero 2025",
"description": "Special edition about climate change",
"category_id": 5,
"language": "es",
"pages": 120,
"pdf_file": "https://storage.example.com/magazines/ng_jan2025.pdf",
"cover_image": "https://storage.example.com/covers/ng_jan2025.jpg",
"issue_date": "2025-01-15"
}'
JavaScript (Fetch)
const response = await fetch('https://primepages.sbs/api/magazines/create.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'm9xK8vQ2pL5nR7gfggertrsfssdg',
'Authorization': 'Bearer ' + userToken
},
body: JSON.stringify({
title: 'Mi Nueva Revista',
category_id: 3,
language: 'es',
pdf_file: 'https://ejemplo.com/magazine.pdf',
description: 'Descripción de mi revista',
pages: 50,
cover_image: 'https://ejemplo.com/cover.jpg'
})
});
const data = await response.json();
console.log(data);
Python (Requests)
import requests
url = "https://primepages.sbs/api/magazines/create.php"
params = {
"api_key": "m9xK8vQ2pL5nR7gfggertrsfssdg",
"token": "65a4f8b3c2d1e9f7a6b5c4d3e2f1a0b9c8d7e6f5"
}
data = {
"title": "Mi Nueva Revista",
"category_id": 3,
"language": "es",
"pdf_file": "https://ejemplo.com/magazine.pdf",
"description": "Descripción de mi revista",
"pages": 50,
"cover_image": "https://ejemplo.com/cover.jpg"
}
response = requests.post(url, params=params, json=data)
print(response.json())
Success Response
Status: 201 Created
{
"success": true,
"message": "Revista publicada exitosamente",
"magazine_id": 42,
"cover_image_saved": "https://storage.example.com/covers/ng_jan2025.jpg"
}
Error Responses
401 Invalid API Key
{
"error": "API Key inválida"
}
401 Invalid or Expired Token
{
"error": "Token inválido o expirado"
}
400 Missing Required Fields
{
"error": "Faltan campos requeridos: title, category_id, language"
}
400 Invalid Category
{
"error": "Categoría no válida"
}
405 Method Not Allowed
{
"error": "Método no permitido"
}
500 Internal Server Error
{
"error": "Error al crear la revista: {error_message}"
}
HTTP Status Codes
| Code | Description |
|---|---|
| 201 | Created - Magazine successfully published |
| 400 | Bad Request - Invalid input data |
| 401 | Unauthorized - Invalid API key or token |
| 405 | Method Not Allowed - Only POST method is accepted |
| 500 | Internal Server Error - Server-side issue |
Special Behavior - cover_image Field
The cover_image field accepts two formats:
- External URL (recommended): Direct URL to an image - stored as-is
- Local filename: Name of a local file in the uploads folder
Note: If no
cover_image is provided, the default value "default-cover.jpg" will be used.
Auto-generated Fields
The following fields are automatically set by the system:
- status: Set to
"published"automatically - is_external_link: Set to
1(true) by default - created_at: Current timestamp
- uploaded_by: ID of the authenticated user
Support
Need Help?
If you have any questions or need assistance with the API, please contact us:
- Email: api@primepages.sbs
- Website: Contact Form
Integration Ready: Use our API to seamlessly integrate magazine publishing into your applications.