Create an Endpoint
Step-by-step guide to creating a REST API endpoint in Spala.
Create an Endpoint
Endpoints connect HTTP routes to functions. When a client sends a request, Spala runs the attached function and returns the result.
Step by step
Open the Endpoints section
Click Endpoints in the left sidebar.
Click Add Endpoint
Click Add Endpoint to open the endpoint editor.
Choose the HTTP method
Pick the method that matches what the endpoint does:
| Method | When to use |
|--------|---------------------------------|
| GET | Read data |
| POST | Create something new |
| PUT | Replace or update something |
| PATCH | Partially update something |
| DELETE | Remove something |
Set the URL path
Enter the path. Use :paramName for dynamic segments:
/api/cases
/api/cases/:id
/api/users/:userId/cases
Dynamic segments become available as params.id, params.userId, etc. in your function.
Attach a function
Select the function that handles this endpoint. Create the function first if needed.
Set authentication
Choose None for public endpoints, or JWT to require a login token. See Protect Your Endpoints.
Save
Click Save. Your endpoint is saved in the project draft and is ready to test in the Playground. Publish when you want live clients to use it.
The endpoint editor Configure method, path, function, and authentication
URL path tips
Use plural nouns for collections and nest related resources:
/products -- all products /products/:id -- one product /products/:id/reviews -- reviews for a product
For actions that are not standard CRUD, use descriptive paths:
POST /api/auth/login POST /orders/:id/cancel POST /api/cases/:id/status
Good to know
Path parameter values are always strings. To use them as numbers (e.g., for a database query), convert with params.id | toNumber.
Managing endpoints
- Edit — Click any endpoint in the list to change its settings. - Duplicate — Right-click an endpoint to copy it. Useful for creating similar routes quickly. - Delete — Right-click and delete. The attached function is not affected. - Generate description — Ask AI to draft a clear endpoint summary for docs and review. - Requests — Open request history to inspect real calls, timing, output, and failures. - Docs visibility — Hide internal routes from generated API docs when they are not meant for clients.
Inputs & Outputs /endpoints/inputs-outputs Handle request data and configure responses Protect Your Endpoints /endpoints/authentication Add JWT authentication