How can I make a REST API call to Civi that creates a CSV file with all the Contacts details (name, email, telephone...) from an specified Smart Group?


  • The REST api isn't capable of making a CSV, it can easily get you the members from the group but formatting those into a CSV is coding you would have to undertake in your code/system and is beyond the scope of CiviCRM. I'll post an answer with an example API call. EDIT The "review" screen helpfully doesn't show the comment which basically says what I said :-) Commented Mar 23, 2021 at 15:51

1 Answer 1


You can't create a csv directly from an API call. But it would be a very simple task to make an API call and then format the results as a csv. One simple option might be to use Google Apps Script to call the API then put the results into a spreadsheet, if you don't want to run this as a standalone script. Or any scripting language you might want to use will have plenty of Google results for creating a csv from an array, which is what the API will return.

  • That's great idea, thanks!
    – Rucc
    Commented Mar 17, 2021 at 10:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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