> ## Documentation Index
> Fetch the complete documentation index at: https://docs.exowizz.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Your first resource

> Create one Resource, then see the API and triggers it unlocks.

This guide walks you through the core Exo concept: Resource creation. You will define one Resource and then use the API and triggers generated from it.

## What is a Resource?

A Resource is a PHP class that tells Exo:

* **Which model** to expose (for example: `User`, `Contact`, `Invoice`)
* **Which data shape** to return through API and webhooks
* **Which trigger events** to emit (`on_create`, `on_update`, `on_delete`)

## Generate it

```bash theme={null}
php artisan exo:resource UserResource --model="App\Models\User" --triggers=on_create,on_update,on_delete
```

This creates `app/Exo/Resources/UserResource.php`.

## Define the required methods

Every Resource implements `name()`, `model()`, `triggers()`, and `transform()`.

```php theme={null}
<?php

namespace App\Exo\Resources;

use Exowizz\Exo\Resource;
use Illuminate\Database\Eloquent\Model;

class UserResource extends Resource
{
    public function name(): string
    {
        return 'user';
    }

    public function model(): string
    {
        return 'App\\Models\\User';
    }

    public function triggers(): array
    {
        return ['on_create', 'on_update', 'on_delete'];
    }

    public function transform(Model $model): array
    {
        return [
            'id' => $model->id,
            'name' => $model->name,
            'email' => $model->email,
            'created_at' => $model->created_at,
            'updated_at' => $model->updated_at,
        ];
    }
}
```

## What Exo generates from this Resource

After app boot, Exo auto-discovers your Resource and registers:

* `GET /exo-api/resources` (resource metadata)
* `GET /exo-api/resources/user` (list)
* `GET /exo-api/resources/user/{id}` (single record)
* `POST /exo-api/resources/user` (create)
* `PUT /exo-api/resources/user/{id}` (update)
* `DELETE /exo-api/resources/user/{id}` (delete)
* Trigger emission for `on_create`, `on_update`, and `on_delete`

## Test the generated API

Confirm registration:

```bash theme={null}
curl -H "Authorization: Bearer YOUR_TOKEN" \
     http://your-app.test/exo-api/resources
```

Create a user:

```bash theme={null}
curl -X POST \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{"name":"Jane Smith","email":"jane@example.com","password":"secret-password"}' \
     http://your-app.test/exo-api/resources/user
```

List users:

```bash theme={null}
curl -H "Authorization: Bearer YOUR_TOKEN" \
     http://your-app.test/exo-api/resources/user
```

## Add medium-level controls

Once this works, add optional methods for:

* Validation with `createRules()` and `updateRules()`
* Ownership with `ownerColumn()` and `is_admin` callback
* Query control with `searchableColumns()` or `applySearch()`
* Operation flags with `supportsCreate()`, `supportsUpdate()`, `supportsDelete()`

## Next steps

<Columns cols={2}>
  <Card title="Resource guides" icon="book-open" href="/resources/overview">
    Continue with transformers, CRUD behavior, ownership, and search.
  </Card>

  <Card title="Webhooks" icon="bell" href="/webhooks/overview">
    See how your Resource triggers become webhook deliveries.
  </Card>
</Columns>
