Skip to main content

Quickstart Guide

Get your MTB Backend API up and running in less than 5 minutes. This guide will walk you through installation, configuration, and making your first API call.

Prerequisites

Before you begin, ensure you have:
  • Node.js version 20.x or higher (up to 24.x)
  • npm version 6.0.0 or higher
  • A code editor (VS Code recommended)
  • Basic knowledge of REST APIs
You can check your Node.js version by running node --version in your terminal.

Installation Steps

1

Clone or Download the Project

Get the MTB Backend source code:
git clone <repository-url> backend-mtb
cd backend-mtb
2

Install Dependencies

Install all required npm packages:
npm install
This will install Strapi 5.33.4 and all dependencies including:
  • @strapi/strapi - Core Strapi framework
  • @strapi/plugin-users-permissions - Authentication
  • better-sqlite3 - Default database
  • axios - HTTP client for Flow integration
3

Configure Environment Variables

Create a .env file in the root directory with the following variables:
# Server Configuration
HOST=0.0.0.0
PORT=1337

# Application Keys (generate random strings)
APP_KEYS=key1,key2,key3,key4

# Database (SQLite by default)
DATABASE_CLIENT=sqlite
DATABASE_FILENAME=.tmp/data.db

# Flow Payment Gateway (optional)
FLOW_API_KEY=your_flow_api_key
FLOW_SECRET_KEY=your_flow_secret_key
FLOW_BASE_URL=https://sandbox.flow.cl/api

# URLs
BACKEND_URL=http://localhost:1337
FRONTEND_URL=http://localhost:5174
Generate secure random strings for APP_KEYS. You can use: openssl rand -base64 32 (run 4 times)
4

Start the Development Server

Launch Strapi in development mode with auto-reload:
npm run develop
You should see output similar to:
Project information

┌────────────────────────────────────────────────┐
│ Time               │ 12:34:56 PM               │
│ Launched in        │ 3254 ms                   │
│ Environment        │ development               │
│ Process PID        │ 12345                     │
│ Version            │ 5.33.4                    │
│ Edition            │ Community                 │
│ Database           │ sqlite                    │
└────────────────────────────────────────────────┘

Actions available

One more thing...
Create your first administrator 💻 by going to the administration panel at:

┌─────────────────────────────┐
│ http://localhost:1337/admin │
└─────────────────────────────┘
5

Create Your First Admin User

Open your browser and navigate to:
http://localhost:1337/admin
Fill in the registration form to create your administrator account:
  • First name
  • Last name
  • Email
  • Password (minimum 8 characters)
Keep your admin credentials secure. This account has full access to all content and settings.

Make Your First API Call

Now that your backend is running, let’s make your first API request.

1. Get API Token (Optional for Public Routes)

For protected endpoints, you’ll need an API token. For public routes, you can skip this step.

2. Fetch Club Information

Retrieve club data using the REST API:
curl http://localhost:1337/api/clubs

3. Create a News Article

Create a new noticia (news article) via the API:
curl -X POST http://localhost:1337/api/noticias \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "titulo": "Nueva temporada de MTB 2026",
      "resumen": "Comienza una nueva temporada llena de desafíos",
      "contenido": [
        {
          "type": "paragraph",
          "children": [
            {"type": "text", "text": "Estamos emocionados de anunciar..."}
          ]
        }
      ],
      "fecha": "2026-03-04",
      "autor": "Admin",
      "publicado": true
    }
  }'

Understanding the Response

Strapi returns data in a standardized format:
{
  "data": [
    {
      "id": 1,
      "documentId": "abc123xyz",
      "attributes": {
        "nombreClub": "MTB Valle Central",
        "emailConacto": "[email protected]",
        "createdAt": "2026-03-04T10:00:00.000Z",
        "updatedAt": "2026-03-04T10:00:00.000Z"
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pageSize": 25,
      "pageCount": 1,
      "total": 1
    }
  }
}
Strapi 5 uses a structured response format:
  • data: Contains the actual content (array for collections, object for single entries)
  • documentId: Unique identifier for each document (replaces id in Strapi 5)
  • attributes: The actual field values
  • meta: Metadata including pagination information

Available API Endpoints

Your MTB Backend exposes these RESTful endpoints:
Content TypeEndpointDescription
Club/api/clubsClub information
Noticias/api/noticiasNews articles
Inscripciones/api/inscripcionsEvent registrations
Inscritos/api/inscritosParticipant profiles
Mensajes/api/mensajesContact messages
Flow Payments/api/flow/pagarPayment processing
All endpoints support standard REST operations: GET (list/retrieve), POST (create), PUT (update), DELETE (remove)

Next Steps

Explore the Admin Panel

Navigate to /admin to manage your content types and create entries

Configure Permissions

Set up public/authenticated access in Settings → Users & Permissions

Set Up Flow Payments

Configure Flow payment gateway for registration processing

Read the Full Installation Guide

Learn about production deployment and advanced configuration

Common Issues

Change the PORT variable in your .env file to a different port:
PORT=1338
If using SQLite (default), ensure the .tmp directory exists and has write permissions:
mkdir -p .tmp
chmod 755 .tmp
Generate secure random keys using:
openssl rand -base64 32
Run this 4 times and add them to .env as a comma-separated string.

Testing the Payment Flow

To test the Flow payment integration:
1

Create a Registration

curl -X POST http://localhost:1337/api/inscripcions \
  -H "Content-Type: application/json" \
  -d '{
    "data": {
      "nombreCompleto": "Juan Pérez",
      "rut": "12345678-9",
      "edad": 28,
      "categoria": "Elite",
      "tipo": "Open",
      "email": "[email protected]",
      "telefono": "+56912345678",
      "monto": 15000,
      "estadoPago": "Pendiente"
    }
  }'
2

Initiate Payment

Use the returned documentId to start the payment process:
curl -X POST http://localhost:1337/api/flow/pagar \
  -H "Content-Type: application/json" \
  -d '{
    "inscripcionId": "<documentId-from-step-1>"
  }'
3

Complete Payment

The API returns a Flow payment URL. Open it in a browser to complete the test payment using Flow’s sandbox credentials.
The Flow integration is located in /src/api/flow/controllers/flow.ts:8 and handles payment creation, signature generation, and webhook confirmations.
You’re now ready to build your mountain biking club platform! 🚴‍♂️

Build docs developers (and LLMs) love