# Custom Objects - how to use API with a custom object type "Relationship"

**URL:** <https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417>\
**Category:** 3rd Party Addons\
**Tags:** development\
**Created:** [September 16, 2022, 3:06pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417 "2022-09-16T15:06:34Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![erthal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/erthal/32/6285_2.png) [@erthal](https://forum.mautic.org/u/erthal)\
**Post date:** [September 16, 2022, 3:06pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/1 "2022-09-16T15:06:35Z")

</div>

Hi Folks,

Custom Objects are great! But I can´t find a way to create a Relationship item using the API. The example provided in the docunentarion refers to a master custom object:

> **[API · acquia/mc-cs-plugin-custom-objects Wiki](https://github.com/acquia/mc-cs-plugin-custom-objects/wiki/API)**
>
> Mautic plugin adding Custom Objects feature. Contribute to acquia/mc-cs-plugin-custom-objects development by creating an account on GitHub.

I need to create a Relashionship linked to the contact AND to the Mater Custom Object. Can you please provide an example? @silavapi have you ever faced this use case?

Best regards

---

<div class="post-metadata">

**Author:** ![gary.harrison](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/gary.harrison/32/2864_2.png) [@gary.harrison](https://forum.mautic.org/u/gary.harrison)\
**Post date:** [September 16, 2022, 5:22pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/2 "2022-09-16T17:22:51Z")

</div>

We would love to know this too - we gave up after a few days…

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [September 16, 2022, 10:20pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/3 "2022-09-16T22:20:55Z")

</div>

I do not think its possible at the moment (at least not using standard CO api endpoints).

I would suggest you look into how the link is made in CO plugin and then develop custom plugin with dedicated endpoint for it. At this point it seems the fastest way.

I did something similar in my situation.

I would however really appreciate this feature within CO plugin, so if/when its possible, please do not hesitate to share (Core Mautic Team).

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [September 20, 2022, 9:26pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/4 "2022-09-20T21:26:04Z")

</div>

@escopecz @fedy any insights that you can offer here?

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [September 21, 2022, 9:16am UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/5 "2022-09-21T09:16:27Z")

</div>

The only API that works is the one linked at the top. We have a “v2” of API built on API Platform for Custom Objects but even that does not allow to create relationships. I know, it should, but so far no customer of ours needed it.

The API Platform will be pushed to the community GitHub repository at some point but since the lack of active testers and that open pull requests are sitting there for months and years it’s discouraging to push any more pull requests to the community. I’m ranting about this as I hop this will make more people active testers so the developers are not discouraged to push new features and bug fixes to the community repository. Right now it’s a waste of time.

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [November 30, 2022, 4:49pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/7 "2022-11-30T16:49:07Z")

</div>

This is such a pity that you cannot create a relationship item yet.

As stated custom objects are amazing - super powerful and thanks to all that created it.

Is there any plans to continue developing the API and extending functionality ?

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [December 1, 2022, 9:32am UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/8 "2022-12-01T09:32:37Z")

</div>

There is no plan to extend the API in the foreseeable future from our side. But I’ll gladly test and review any community contribution on this topic!

---

<div class="post-metadata">

**Author:** ![pierre\_a](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/pierre_a/32/7031_2.png) [@pierre\_a](https://forum.mautic.org/u/pierre_a)\
**Post date:** [June 26, 2024, 3:28pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/9 "2024-06-26T15:28:16Z")

</div>

Hello @escopecz,

Can you confirm me this route " `PATCH/PUT api/contacts/[contact_id]/edit`" ([API · acquia/mc-cs-plugin-custom-objects Wiki · GitHub](https://github.com/acquia/mc-cs-plugin-custom-objects/wiki/API)) is working ?

I have been doing a lot of tests with no results. Impossible to create “custom object” from API…

Can you help us?  
Pierre

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [June 26, 2024, 10:30pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/10 "2024-06-26T22:30:14Z")

</div>

I think this feature is not available. You can’t pair vis API.

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [June 27, 2024, 8:39am UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/11 "2024-06-27T08:39:54Z")

</div>

Yes, our customers are using it. There are also tests that are confirming that it is working [mc-cs-plugin-custom-objects/Tests/Functional/EventListener/ApiSubscriberTest.php at 3593179ae431e343179da25371d4df03617ec522 · acquia/mc-cs-plugin-custom-objects · GitHub](https://github.com/acquia/mc-cs-plugin-custom-objects/blob/3593179ae431e343179da25371d4df03617ec522/Tests/Functional/EventListener/ApiSubscriberTest.php)

But it won’t create custom objects. It can create custom items and link them with the contact.

---

<div class="post-metadata">

**Author:** ![ncmon](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ncmon/32/11887_2.png) [@ncmon](https://forum.mautic.org/u/ncmon)\
**Post date:** [June 28, 2024, 3:47pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/12 "2024-06-28T15:47:13Z")

</div>

does anybody managed to use it this plugin in mautic 5?  
i’ve tested all versions and with no success… i’m using mautic 5.1

---

<div class="post-metadata">

**Author:** ![erthal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/erthal/32/6285_2.png) [@erthal](https://forum.mautic.org/u/erthal)\
**Post date:** [July 1, 2024, 3:56pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/13 "2024-07-01T15:56:47Z")

</div>

@silavapi, custom objectds will be compatible with mautic 5.x ? I am just using this plugin because it was published from Acquia

---

<div class="post-metadata">

**Author:** ![silavapi](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/silavapi/32/7424_2.png) [@silavapi](https://forum.mautic.org/u/silavapi)\
**Post date:** [July 1, 2024, 4:03pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/14 "2024-07-01T16:03:57Z")

</div>

I don’t know, but I would recommend you follow this PR as I’m guessing that’s the most likely place to receive updates and help with testing:

> <https://github.com/acquia/mc-cs-plugin-custom-objects/pull/338>
>
> \<!-- ## Which branch should I use for my PR?
> 
> Assuming that:
> 
> a = current ma…jor release
> b = current minor release
> c = future major release
> 
> \* a.x for any features and enhancements (e.g. 4.x)
> \* a.b for any bug fixes (e.g. 4.0, 4.1, 4.2)
> \* c.x for any features, enhancements or bug fixes with backward compatibility breaking changes (e.g. 5.x) --\>
> 
> | Q | A
> | -------------------------------------- | ---
> | Bug fix? (use the a.b branch) | \[\]
> | New feature/enhancement? (use the a.x branch) | \[\]
> | Deprecations? | \[\]
> | BC breaks? (use the c.x branch) | \[\]
> | Automated tests included? | \[\] 
> | Related user documentation PR URL | mautic/mautic-documentation#... 
> | Related developer documentation PR URL | mautic/developer-documentation#... 
> | Issue(s) addressed | Fixes #... 
> 
> \<!--
> Additionally (see https://contribute.mautic.org/contributing-to-mautic/developer/code/pull-requests#work-on-your-pull-request):
> - Always add tests and ensure they pass.
> - Bug fixes must be submitted against the lowest maintained branch where they apply
> (lowest branches are regularly merged to upper ones so they get the fixes too.)
> - Features and deprecations must be submitted against the "4.x" branch.
> \--\>
> 
> \#### Description:
> 
> Replaces PRs #298, #308, #316
> \<!--
> Please write a short README for your feature/bugfix. This will help people understand your PR and what it aims to do. If you are fixing a bug and if there is no linked issue already, please provide steps to reproduce the issue here.
> \--\>
> 
> \#### Steps to test this PR:
> 
> \<!--
> This part is really important. If you want your PR to be merged, take the time to write very clear, annotated and step by step test instructions. Do not assume any previous knowledge - testers may not be developers.
> \--\>
> 1. Open this PR for testing locally (see docs on testing PRs \[here\](https://contribute.mautic.org/contributing-to-mautic/tester))
> 2.
> 
> \<!--
> If you have any deprecations, list them here along with the new alternative.
> If you have any backwards compatibility breaks, list them here.
> \--\>

---

<div class="post-metadata">

**Author:** ![erthal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/erthal/32/6285_2.png) [@erthal](https://forum.mautic.org/u/erthal)\
**Post date:** [July 1, 2024, 6:25pm UTC](https://forum.mautic.org/t/custom-objects-how-to-use-api-with-a-custom-object-type-relationship/25417/15 "2024-07-01T18:25:50Z")

</div>

Thank you! But tis PR will include customobjects? This is a pluggin…
