I'm trying to register a new user account to my CiviCRM site and also to create a contact in the CiviCRM system for him. I want to do that via the REST API call application that I'm writing in python. After some investigations, I saw that I need to send the request to Drupal system and not to The CiviCRM module.

Can anyone tell me how can I do that REST API call?

My CiviCRM is on Bitnami with AWS instance, with Drupal.

Thanks a lot


Since that's straight drupal I would try the drupal docs and if you're still stuck you might get more responses at https://drupal.stackexchange.com.

Another thing you could try but I don't know if it will work is to use civi's api Profile.submit. If you have a profile at admin - customize - profiles which is configured for Drupal User Registration and allows creating users, you might be able to pass in the right parameters to include the account name/email to create the account.


This API doesn't exist in CiviCRM but if you want to stick with CiviCRM API (which is better if you want to keep it CMS agnostic), you could create a new CiviCRM API which is not too complex if you are a developer.

With civix installed, it would require to :

  1. create an extension `civix generate:module thenewextension
  2. go in thenewextension and generate the api civix generate:api MyEntity myaction
  3. a new file should be created in api/v3/MyEntity/myaction.php
  4. in the php, call the CMS agnostic function $ufID = CRM_Core_BAO_CMSUser::create($params, $mail); and add the logic you want
  5. activate the extension
  6. you should be able to see your api and test it in `https://www.mysite.com/civicrm/api

To call the API using REST, you need to call the url with the correct parameters (or more likely use a python library that will do much of the work for you) : https://www.mysite.com/sites/all/mdoules/civicrm/extern/rest.php?entity=MyEntity&action=myaction&api_key=(myAPIkey)&key=(mySiteKey)&json={“first_name":"xxx","last_name":"yyy","username":"zzz"}

  • myAPIkey must be created on a contact with the api permission in the database -> civicrm_contact table (or use a handy extension https://civicrm.org/fr/extensions/api-key)
  • mySiteKey is in civicrm.settings.php
  • json contains the parameters of your api call

Your Answer

