Endpoints

Actions

Actions are a way to provide actions for your users with a full integration in Laravel Rest Api. It includes the strong search feature to enable security and power.

How to use it

When you are ready to perform an action, you can use the operate method by making a POST call:

// (POST) api/users/actions/send-welcome-notification
{
    "fields": [
      { "name": "expires_at", "value": "2023-04-29" }
    ]
}

You may specify the fields provided by the user using the fields argument. You can have full access to the fields and validation in the resource details.

send-welcome-notification is the uriKey of the action provided in the resource details.

As a response, you'll receive the number of models that were impacted:

{
  "data": {
    "impacted": 150
  }
}

Complex filtering

In most cases you'll want to specify which models will be dynamically impacted by the action. The action endpoint provides full support for the search operation. If you are not familiar with the search method, have a quick look at the documentation.

Specify your arguments in the search argument:

// (POST) api/users/actions/send-welcome-notification
{
    "fields": [
      { "name": "expires_at", "value": "2023-04-29" }
    ],
    "search": {
        "filters": [
            { "field": "has_received_welcome_notification", "value": false }
        ]
    }
}

Response

As a response you'll receive the number of models that were impacted.

{
  "data": {
    "impacted": 2
  }
}

Standalone actions

A standalone actions is an action that does not require any models to run. You may know if an action is standalone in the detail endpoint with the is_standalone key.

Standalone actions works the same, you just can't specify a search operation.


Copyright © 2024