# For hosts with no Composer. How to add the API to a php script with require?

**URL:** <https://forum.mautic.org/t/for-hosts-with-no-composer-how-to-add-the-api-to-a-php-script-with-require/17380>\
**Category:** Product Support\
**Created:** [December 11, 2020, 10:24pm UTC](https://forum.mautic.org/t/for-hosts-with-no-composer-how-to-add-the-api-to-a-php-script-with-require/17380 "2020-12-11T22:24:15Z")\
**Posts on this page:** 1\
**Showing post:** 12

<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:** [September 13, 2021, 10:13am UTC](https://forum.mautic.org/t/for-hosts-with-no-composer-how-to-add-the-api-to-a-php-script-with-require/17380/12 "2021-09-13T10:13:11Z")

</div>

Postman is an API testing tool. It is a true delight to use.  
[https://www.postman.com/](https://www.postman.com/)

Snipplet to create a contact with simple identification:

Start your code with defining the variables:

```auto
<?php
$loginname = 'apiuser';
// Loginname of your API user
$password = 'yourpasswordhere';
// This is the password of the API user
$siteurl = yoursiteurl.tld;
// example: mymautic.com

```

Add the payload:

```auto
$email = 'captain_enterprise-d@starfleet.com';
$firstname = 'Jean-Luc';
$lastname = 'Picard';
$tag = 'purchased';

```

And execute the API call:

```auto
$curl = curl_init();
// Set some options - we are passing in a user agent too here
  curl_setopt_array($curl, array(
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_URL => "https://".$loginname.":".$password."@".$siteurl."/api/contacts/new",
  CURLOPT_USERAGENT => 'Mautic Connector by Joey',
  CURLOPT_POST => 1,
// posting the payload
  CURLOPT_POSTFIELDS => array(
    'firstname' => $firstname,
    'lastname' => $lastname,
    'email' => $email,
    'tags' => $tag
  )
));
curl_exec($curl);

```

That’s it.

If you go with Postman, here are a bunch of API scripts as a Postman collection:

> [@Mautic Postman collection](https://forum.mautic.org/t/mautic-postman-collection/15198):
>
> Hi folks, I created a Postman collection for some of Mautic’s REST API that i often use. Feel free to download: LMK if you have any issues

---

_[View the full topic](https://forum.mautic.org/t/for-hosts-with-no-composer-how-to-add-the-api-to-a-php-script-with-require/17380)._
