I know there's been a lot of work to deprecate the extern endpoints in CiviCRM, and the extern endpoints don't work in Drupal 8 without a lot of finagling. The documentation isn't updated to reflect a new way of using D8 REST endpoints, nor is API Explorer. Does anyone know what the "correct" endpoint is?


2 Answers 2


The comment above is right - the answer for this is very much in flux, and this is a temporary hack - but nevertheless, if you need a REST endpoint today, you can do this:

  • Copy the entire extern directories into your web/libraries/civicrm directory.
  • Copy the template for civicrm.config.php into web/libraries.

Here are the commands I used:

cp -r <drupalroot>/vendor/civicrm/civicrm-core/extern <drupalroot>/web/libraries/civicrm/extern
cp <drupalroot>/web/modules/contrib/civicrm/civicrm.config.php.drupal <drupalroot>/web/libraries/civicrm/civicrm.config.php
  • I used a symbolic link to <drupal root>/vendor/civicrm/civicrm-core/extern in <drupal root>/web/libraries/civicrm/core since that will, I hope, make sure that the folder remains in date. i May 5, 2021 at 17:03

I just installed a CiviCRM and Drupal 9 instance (5.40.1). These were my steps:

  • I enabled the new authx extension cv ext:enable authx
  • I allowed the authenticate with the api_key in a special header cv ev 'Civi::settings()->set("authx_xheader_cred",["api_key"]);' The auth extension does not have a configuration screen, yet.
  • I added site key as an extra protection cv ev 'Civi::settings()->set("authx_guards",["site_key"]);'.
  • I flushed the CiviCRM cache cv flush

And now the following CURL command can be used to call the REST api:

curl -X GET --location "http://<<server>>/civicrm/ajax/rest? 
entity=Contact&action=get&json=1" \
-H "X-Civi-Auth: Bearer <<api_key>>" \
-H "X-Civi-Key: <<site_key>>" \
-H "Accept: application/json" \
-H "X-Requested-With: XMLHttpRequest"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.