Skip to content
John Linhart edited this page Jun 7, 2019 · 14 revisions

Create/Update custom items together with contact

The Custom Object plugin listens on [POST api/contacts/new](https://developer.mautic.org/#create-contact) request and if the payload contains custom items it will save those and link them to the contact.

Route POST api/contacts/new

Example payload:

The example payload bellow expects that there is some Custom Object called Products (with alias products). If such Custom Object doesn't exist it will return HTTP status 404 and no contact nor Custom Item will be saved.

If you wish to insert a Custom Item then do not send its id. However, if you wish to update a Custom Item then you must provide the ID.

Mautic will firstly validate all the Custom Objects, Custom Items and Custom Fields. Then it will validate the contact itself. If all validations passes it will save the contact, save the Custom Items together with Custom Field values and then it will link all the custom items to the contact.

The format of payload bellow can be used in the request and same format will be sent in the response.

{
    "email": "john@doe.email",
    "firstname": "John",
    "customObjects": {
        "products": {
            "id": 1,
            "customItems": {
                "23": {
                    "id": 23,
                    "name": "Hello From API2",
                    "language": null,
                    "category": null,
                    "isPublished": true,
                    "dateAdded": "2019-06-07T11:52:01+00:00",
                    "dateModified": "2019-06-07T11:52:01+00:00",
                    "createdBy": 1,
                    "modifiedBy": 1,
                    "customFields": {
                        "website": "https://mautic.org",
                        "in-stock": 45,
                        "multi": ["yellow", "blue"],
                        "sku": "2348720",
                        "color": "brown"
                    }
                }
            }
        }
    }
}
Clone this wiki locally