# API Resources

https://dev.wisecp.com/es/api-resources

How the endpoints are grouped, how a name becomes a permission, and how to find the one you need.

## Overview

The API is organised by resource, not by table. A resource is an area of the product: clients, invoices, services, products, tickets. Inside it, an action is one thing you can do.

That pair is the API's whole naming system. `Clients/GetClients` is the route's identity and the permission you tick when issuing a key. It is also the string in a `403` message and the name the documentation uses. Learn one of them and you know the rest.

Actions read as verbs on purpose: `Get`, `Create`, `Update`, `Delete`, `Bulk`. The HTTP method agrees with the verb, so a name and a method never tell you different stories.

## Structure

The admin surface groups its resources into families. You rarely need more than one family for a given integration, which is also the natural boundary for the permissions you grant.

- **system · reference**: Health, key identity, and the lists every other call fills its fields from: currencies, countries, states, cities, languages, billing cycles, statuses.
- **clients · admins · affiliates**: Customer records with their addresses, groups, documents and access, plus staff accounts and the affiliate programme.
- **orders · invoices · financial · services**: The money path end to end: an order becomes an invoice, a paid invoice becomes a service, and a service renews.
- **products · modules**: What you sell and what provisions it: products with their pricing, add-ons and requirements, plus the module registry behind them.
- **tickets · knowledgebase · website**: Departments and ticket traffic, published articles, and the public site's pages and menus.
- **settings · automation · languages · notifications · tools**: The installation's own machinery: configuration, scheduled work, language packs, notification templates and maintenance tools.

The client surface carries a much shorter list, because a customer manages one account rather than an installation. It is covered in its own article.

### Finding an Endpoint

Work down, not up. Pick the family, open its reference article in this section, and read the action list. Each entry gives the method, the path, the permission name and a working sample in four languages.

If you know the object but not the family, the name usually gives it away. Anything about a customer's own record lives in `clients`. Anything with a price on it lives in `invoices` or `orders`, and anything running on a server lives in `services`.

## Example

Code that already runs inside an installation does not need HTTP, a key or a network round trip. It can call the same resource in process, and gets back the same envelope.

```php
// over HTTP:  GET /api/v1/admin/clients?limit=5
// in process, from a module, a cron handler or a hook listener:
$result = \WISECP\Api\Kernel::internal('Clients/GetClients', [], ['limit' => 5]);

$clients = $result['data']  ?? [];
$total   = $result['meta']['total'] ?? 0;

// the client surface needs to be told whose account it is acting on
$me = \WISECP\Api\Kernel::internal('client:Account/GetMe', ['owner_id' => 42]);
```

## Pitfalls

> **A resource is not a table**
> 
> Creating a client writes several tables, fires hooks and may send a notification. Reading one merges records that are stored apart. Expecting a column-for-field mapping will mislead you; read the action's field list instead of the schema.

> **Installed modules can add groups of their own**
> 
> A module may publish endpoints under a group named `Module:{Type}/{Name}`. They appear as their own permission checkboxes and behave like any other endpoint. They belong to that module and travel with it, so an integration that relies on one should say which module it needs.

## Related Articles

- [The WISECP API](https://dev.wisecp.com/en/the-wisecp-api)
- [API Authentication and Permissions](https://dev.wisecp.com/en/api-authentication-and-permissions)
- [Request and Response Format](https://dev.wisecp.com/en/request-and-response-format)
- [Client API Overview](https://dev.wisecp.com/en/client-api-overview)
