Every automation on a Joomla site, from an AI assistant writing drafts to a nightly import or a mobile app, runs through the same door: the Web Services API that has been in core since Joomla 4.0. This is the practical introduction we give developers who start with it: how authentication really works, what the requests and responses look like, and the details the official docs leave you to discover.
How the API is put together
- The entry point is
/api/index.php/v1/…, a separate application next to the site and the administrator. - Each resource comes from a plugin in the webservices group: Content, Users, Menus, Modules, Tags, Media, Redirect, Config and more. Disable the plugin and its endpoints disappear.
- Authentication comes from plugins in the api-authentication group: Token and Basic.
- Requests and responses use JSON:API (
application/vnd.api+json). - Every route is a standard set:
GETlist,GET /:id,POST,PATCH /:id,DELETE /:id.
// plugins/webservices/content/src/Extension/Content.php (Joomla 6.2, shortened)
public function onBeforeApiRoute(BeforeApiRouteEvent $event): void
{
$router = $event->getRouter();
$router->createCRUDRoutes('v1/content/articles', 'articles', ['component' => 'com_content']);
$router->createCRUDRoutes('v1/content/categories', 'categories', ['component' => 'com_categories', 'extension' => 'com_content']);
// …
}
One consequence surprises people: reading is not public. The content routes are registered with public => false, so even GET on published articles needs a token. The API is for managing a site, not for serving it. For public data, use the site's normal pages or a feed.
Authentication
Token (use this)
Each user can have an API token: User → Edit → Joomla API Token tab. It's sent as a bearer token:
# terminal
curl -s -H "Authorization: Bearer $JOOMLA_TOKEN" \
-H "Accept: application/vnd.api+json" \
"https://example.com/api/index.php/v1/content/articles?page[limit]=5"
Two things to set up first:
- By default only Super Users can have a token. To give one to a restricted integration user, add their group in Plugins → User – Joomla API Token → Allowed User Groups.
- The token acts with that user's permissions. An integration that only writes articles to one category should be a user who can only do that. API permissions are Joomla ACL, nothing separate.
Basic (disable it unless you need it)
The Basic plugin accepts a username and password on each request. It's handy for a quick test and a liability on a live site, because it turns the API into a login form without MFA. If nothing uses it, disable API Authentication – Basic.
Reading: lists, filters, paging
# terminal – published articles in category 11 containing "upgrade", newest first, 10 per page
curl -s -G -H "Authorization: Bearer $JOOMLA_TOKEN" -H "Accept: application/vnd.api+json" \
--data-urlencode "filter[category]=11" \
--data-urlencode "filter[state]=1" \
--data-urlencode "filter[search]=upgrade" \
--data-urlencode "list[ordering]=a.publish_up" \
--data-urlencode "list[direction]=DESC" \
--data-urlencode "page[limit]=10" \
--data-urlencode "page[offset]=0" \
"https://example.com/api/index.php/v1/content/articles"
The response, shortened:
{
"links": { "self": "…/content/articles?page[offset]=0&page[limit]=10", "next": "…page[offset]=10…", "last": "…" },
"data": [
{
"type": "articles",
"id": "103",
"attributes": {
"title": "Upgrade a Joomla Site with CiviCRM to Joomla 6",
"alias": "upgrade-joomla-civicrm-site-to-joomla-6",
"state": 1,
"language": "*",
"metadesc": "…",
"publish_up": "2026-10-16 08:46:09"
},
"relationships": {
"category": { "data": { "type": "categories", "id": "23" } },
"created_by": { "data": { "type": "users", "id": "42" } }
}
}
],
"meta": { "total-pages": 2 }
}
Notes from real use:
- The id is a string in
data[].id, as JSON:API requires. Cast it. list[ordering]only accepts columns the model allows as filter fields. Anything else is silently ignored, and the default order applies.- Follow
links.nextinstead of computing offsets. It's correct even when the total changes while you page. - A single item (
GET …/articles/103) includes the full text, images, metadata and custom fields by name.
Writing: create, update, delete
# terminal – create an unpublished article
curl -s -X POST -H "Authorization: Bearer $JOOMLA_TOKEN" \
-H "Content-Type: application/json" -H "Accept: application/vnd.api+json" \
"https://example.com/api/index.php/v1/content/articles" \
-d '{
"title": "Testing the Joomla API",
"catid": 11,
"articletext": "<p>Intro.</p><hr id=\"system-readmore\"><p>Rest of the article.</p>",
"language": "*",
"state": 0,
"metadesc": "A test article created through the Joomla Web Services API."
}'
- The body field is
articletext. Joomla splits it into intro and full text at the read-more marker, exactly like the editor. aliasis optional and generated from the title. Send it when URLs matter.- Custom fields go by their field name at the top level (
"price": "19"). The controller moves them intocom_fields. PATCHsends only the fields you change. Tags you don't send are kept.DELETEonly works on trashed items (state: -2), the same rule as in the back end. Two steps, on purpose.
# terminal – change one field
curl -s -X PATCH -H "Authorization: Bearer $JOOMLA_TOKEN" -H "Content-Type: application/json" \
"https://example.com/api/index.php/v1/content/articles/103" -d '{"metadesc": "New description."}'
Errors you will meet
| Response | Usual cause |
|---|---|
401 {"errors":[{"title":"Forbidden"}]} | missing/wrong token, token plugin disabled, or the user's group not allowed tokens |
404 Resource not found | the webservices plugin for that resource is disabled, or a typo in the route |
403 on write | the user lacks create/edit permission in that category |
400 with a field message | form validation, e.g. a duplicate alias in the category, or a missing catid |
| HTML instead of JSON | a PHP error or a security plugin intercepting /api/; check the server error log |
From the browser: CORS
Calls from JavaScript on another domain need CORS headers. Global Configuration → Server → Web Services → Enable CORS, with allowed origins, headers and methods. Never put a token in front-end JavaScript: anyone can read it. Browser apps should talk to your own backend, and that backend calls Joomla.
Your own component in the API
A custom component joins the API with two pieces: an api/components/com_example folder with controllers and JSON:API views, and a webservices plugin that registers the routes with createCRUDRoutes(). Core's com_contact and its plugin are the cleanest example to copy.
Security checklist
- Disable the webservices plugins you don't use, and Basic authentication.
- One dedicated user per integration, with its own group and minimal permissions.
- Tokens live in server-side environment variables, and get rotated when people leave.
- Keep Joomla updated. The worst Joomla flaw of recent years (CVE-2023-23752) was in the API's access check.
- If nothing calls the API at all, deny
/api/in the web server.
Next: put an AI assistant on top of it with a Joomla MCP server.
