The goal is to have an endpoint that takes starting id and limit parameters and returns a filtered list of Sprout Form submissions as JSON without the JSON Feed v1 metadata bits.

I've tried to set up an endpoint with Element API, but haven't gotten that working yet. I suspect my elementType is off. I know that there are integration options available in Sprout Forms but from the documentation it looks like it's only pushing the submissions as they come in, not as requested. I've got the endpoint set up on a single PHP page with it's own db table now as a proof of concept.

Is the best way forward to: a) Complete configuring the element API endpoint. b) Build a native Sprout Forms data integration. c) Use custom PHP to get the data and return the JSON. d) Or something else?

1 Answer 1


Please see the Sprout Forms Element API documentation page. If it doesn't address your answer, please update your question and I can clarify further.

Here's the example from the docs of both a Form and Form Entries being retrieved from the Element API:


use barrelstrength\sproutforms\elements\Form;
use barrelstrength\sproutforms\elements\Entry;

return [
    'endpoints' => [
        'api/sproutforms/<formId:\d+>.json' => function($formId) {
            return [
                'elementType' => Form::class,
                'criteria' => ['id' => $formId],
                'one' => true,
                'transformer' => function(Form $form) {
                    foreach ($form->getFieldLayout()->getTabs() as $tab) {
                        foreach ($tab->getFields() as $field) {
                            $fields[] = [
                                'field' => $field,
                                'folder' => $field->getFieldInputFolder()

                        $tabs[] = [
                            'title' => $tab->name,
                            'fields' => $fields

                    return [
                        'handle' => $form->handle,
                        'tabs' => $tabs
        'api/sproutforms/<formId:\d+>/entries.json' => function($formId) {
            return [
                'elementType' => Entry::class,
                'criteria' => [
                    'formId' => $formId,
                    'status' => 'unread'
                'paginate' => true,
                'transformer' => function(Entry $entry) {
                    return [
                        'id' => $entry->id,
                        'dateCreated' => $entry->dateCreated,
                        'title' => $entry->title,
                        'customField' => $entry->customField,

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.