# Api call example ?

**URL:** <https://forum.mautic.org/t/api-call-example/3060>\
**Category:** Product Support\
**Created:** [December 24, 2015, 9:23am UTC](https://forum.mautic.org/t/api-call-example/3060 "2015-12-24T09:23:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leox](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/leox/32/12600_2.png) [@Leox](https://forum.mautic.org/u/Leox)\
**Post date:** [December 24, 2015, 9:23am UTC](https://forum.mautic.org/t/api-call-example/3060/1 "2015-12-24T09:23:37Z")

</div>

Hello,  
  
  
  
I have installed Mautic on my own server. Everything works well ! Thanks a lot.  
  
  
  
Now, i want to connect my application (Node JS / Express) to Mautic by the API.  
  
There are different libraries from NPM to connect the oauth2 protocol.  
  
I’m ready to use this one : [simple-oauth2](https://github.com/andreareginato/simple-oauth2)  
  
**There are 3 strategies : Authorization Code flow,Password Credentials Flow,Client Credentials Flow.**  
  
 **_ ~~=\> What’s the good one ? Authorization Code flow right ?~~ _**  
  
  
  
I didn’t succeed, i’m getting always a bad message about authorization from mautic.  
  
  
  
~~_=\> Can somebody send me an example of the OAUTH2 HTTP call ?_  
  
I just want an example about the url and parameters…~~  
  
**_Edit !_**  
  
 **[https://github.com/mautic/developer-documentation/blob/master/source/includes/\_api\_authorization\_oauth2.md](https://github.com/mautic/developer-documentation/blob/master/source/includes/_api_authorization_oauth2.md)**  
  
 **[https://developer.mautic.org/#oauth-2](https://developer.mautic.org/#oauth-2)**  
  
   
  
My last try with a simple http request :  
  
http://[MY MAUTIC]/oauth/v2/authorize?grant\_type=authorization\_code&response\_type=code&client\_id=1\_59og0q5y684kss048swko408sgo0w4gssskc0goko48o84gscg&state=TESTNUMBER1&redirect\_uri=http://[MY MAUTIC]  
  
  
  
~~=\> redirect to /oauth/v2/authorize\_login (302 & 200)  
  
=\> i don’t see any callback in the access logs of my app~~  
  
  
  
**_Edit !_**  
  
**=\> It work’s… i just need to login with my personnal account.**  
  
**I dont understand how it works… how my app can deal with this login page ?**  
  
  
  
http://[MY MAUTIC]/oauth/v2/token?code=[GET FROM CALLBACK ?]&grant\_type=authorization\_code&client\_id=1\_59og0q5y684kss048swko408sgo0w4gssskc0goko48o84gscg&client\_secret=1csq0ylkc3dw0w0004os8ssos4wg0k0okgsoo08ksc80s4kgk4&redirect\_uri=http://[MY MAUTIC]  
  
  
  
=\> OK, i’m getting the token  
  
  
  
I have checked the [api-lib](https://github.com/mautic/api-library/blob/master/lib/Auth/OAuth.php) and forums about Mautic Api and FOS Bundle Oauth and noooo way  
  
  
  
**_Edit !_**  
  
**Api details here :**  
  
=\> [https://developer.mautic.org/#create-lead](https://developer.mautic.org/#create-lead)  
  
  
  
endpoint [here](https://github.com/mautic/api-library/blob/master/apitester/endpoints/Leads.json) is wrong ? “leads/edit/{id}” ??  
  
  
  
Merci beaucoup for your help,  
  
Merry christmas !

---

<div class="post-metadata">

**Author:** ![Leox](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/leox/32/12600_2.png) [@Leox](https://forum.mautic.org/u/Leox)\
**Post date:** [December 24, 2015, 9:23am UTC](https://forum.mautic.org/t/api-call-example/3060/2 "2015-12-24T09:23:37Z")

</div>

Hello,

I have installed Mautic on my own server. Everything works well ! Thanks a lot.

Now, i want to connect my application (Node JS / Express) to Mautic by the API.  
There are different libraries from NPM to connect the oauth2 protocol.  
I’m ready to use this one : [simple-oauth2](https://github.com/andreareginato/simple-oauth2)  
There are 3 strategies : Authorization Code flow,Password Credentials Flow,Client Credentials Flow.  
 =\> What’s the good one ? Authorization Code flow right ?

I didn’t succeed, i’m getting always a bad message about authorization from mautic.

=\> Can somebody send me an example of the OAUTH2 HTTP call ?  
I just want an example about the url and parameters…  
Edit !  
 [https://github.com/mautic/developer-documentation/blob/master/source/includes/\_api\_authorization\_oauth2.md](https://github.com/mautic/developer-documentation/blob/master/source/includes/_api_authorization_oauth2.md)  
 [https://developer.mautic.org/#oauth-2](https://developer.mautic.org/#oauth-2)  
   
My last try with a simple http request :  
http://[MY MAUTIC]/oauth/v2/authorize?grant\_type=authorization\_code&response\_type=code&client\_id=1\_59og0q5y684kss048swko408sgo0w4gssskc0goko48o84gscg&state=TESTNUMBER1&redirect\_uri=http://[MY MAUTIC]

=\> redirect to /oauth/v2/authorize\_login (302 & 200)  
=\> i don’t see any callback in the access logs of my app

Edit !  
=\> It work’s… i just need to login with my personnal account.  
I dont understand how it works… how my app can deal with this login page ?

http://[MY MAUTIC]/oauth/v2/token?code=[GET FROM CALLBACK ?]&grant\_type=authorization\_code&client\_id=1\_59og0q5y684kss048swko408sgo0w4gssskc0goko48o84gscg&client\_secret=1csq0ylkc3dw0w0004os8ssos4wg0k0okgsoo08ksc80s4kgk4&redirect\_uri=http://[MY MAUTIC]

=\> OK, i’m getting the token

I have checked the [api-lib](https://github.com/mautic/api-library/blob/master/lib/Auth/OAuth.php) and forums about Mautic Api and FOS Bundle Oauth and noooo way

Edit !  
Api details here :  
=\> [https://developer.mautic.org/#create-lead](https://developer.mautic.org/#create-lead)

endpoint [here](https://github.com/mautic/api-library/blob/master/apitester/endpoints/Leads.json) is wrong ? “leads/edit/{id}” ??

Merci beaucoup for your help,  
Merry christmas !

---

<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 28, 2015, 5:38pm UTC](https://forum.mautic.org/t/api-call-example/3060/3 "2015-12-28T17:38:38Z")

</div>

Wow, you did great! Thanks for the updates of your work. The most effective way how to get the possible endpoints is to look at the code directly. LeadBundle’s API routes are here:

[https://github.com/mautic/mautic/blob/staging/app/bundles/LeadBundle/Config/config.php#L59-L128](https://github.com/mautic/mautic/blob/staging/app/bundles/LeadBundle/Config/config.php#L59-L128)

To answer your last question, the right endpoint is `/leads/{id}/edit`

---

<div class="post-metadata">

**Author:** ![kinnaert](https://avatars.discourse-cdn.com/v4/letter/k/edb3f5/32.png) [@kinnaert](https://forum.mautic.org/u/kinnaert)\
**Post date:** [August 25, 2016, 3:02pm UTC](https://forum.mautic.org/t/api-call-example/3060/4 "2016-08-25T15:02:01Z")

</div>

I’m trying to connect Zapier with Mautic, I’ve install github API so now there’s /lib folder in my root directory, but zapier can’t connect it gets HTTP 403 error [http://MyWebSiteExample.com/oauth/v2/authorize?response\_type=](http://MyWebSiteExample.com/oauth/v2/authorize?response_type=)…

There’s no /oauth/ folder in my install or the api library I installed???

As a troubleshooting test I was able to go to [mautic.net](http://mautic.net) setup a test account and connect zapier to it there, I see it going to the /oauth/ path at [mautic.net](http://mautic.net) no problem and authorization happens as expected, but with my self hosted install, I’m getting this 403 error?

I tried going to the apitester/ folder to see if I could test my api is working but I just get and error, I’ve seen screen shoots of the tester, but I can’t access it to test mautic api either  
when I browse to apitester I get {“error”:“access\_denied”,“error\_description”:“OAuth2 authentication required”}

---

<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:** [February 2, 2020, 10:54pm UTC](https://forum.mautic.org/t/api-call-example/3060/5 "2020-02-02T22:54:35Z")

</div>


