---
title: "API resources — Forms for Laravel | Roundly"
description: "Render a form and its groups and fields as JSON for SPA or mobile frontends with the bundled JsonResources."
url: https://roundly-consulting.com/open-source/docs/forms-for-laravel/api-resources
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Forms for Laravel](https://roundly-consulting.com/open-source/docs/forms-for-laravel.md)

# API resources

Ready-made JsonResources render a form and its structure for API responses:

```php
use RoundlyConsulting\Forms\Facades\Forms;
use RoundlyConsulting\Forms\Resources\FormResource;

$form = Forms::find('my-form');

return FormResource::make($form);
```

FormResource nests GroupResource (when groups are loaded), which nests FieldResource (when fields are loaded) — including each field’s options, validations and autofill state. Forms::find() eager-loads both, in order. The response looks like this:

```json
{
  "data": {
    "key": "contact",
    "name": "Contact us",
    "expires_at": null,
    "is_public": true,
    "groups": [
      {
        "key": "details",
        "name": "Your details",
        "order": 0,
        "fields": [
          {
            "key": "email",
            "name": "Email",
            "help": null,
            "type": "email",
            "autofill": { "enabled": false, "value": null },
            "options": { "has_options": false, "values": null },
            "validations": { "has_validations": true, "validations": ["required", "email"] },
            "order": 1
          }
        ]
      }
    ]
  }
}
```

expires\_at is rendered as a date-time string when set. Extend the resources in your app if your frontend needs more — for example a field’s conditions.

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/forms-for-laravel.md)
