Skip to content

Adding people to Codacy programmatically#

There are scenarios where manually adding people on the Codacy UI is inconvenient or time-consuming. For example, you're adding many people to Codacy, such as when initially onboarding all developers within a team.

To add people programmatically, use the Codacy API endpoint addPeopleToOrganization by performing an HTTP POST request to /people, specifying a list of email addresses in the body of the request:

  -H 'Content-Type: application/json' \
  -H 'api-token: <API_KEY>' \
  -d '["<EMAIL#1>", "<EMAIL#2>"]'

Substitute the placeholders with your own values:

  • API_KEY: Account API token used to authenticate on the Codacy API.
  • GIT_PROVIDER: Git provider hosting of the organization, using one of the values in the table below. For example, gh for GitHub Cloud.

    Value Git provider
    gh GitHub Cloud
    ghe GitHub Enterprise
    gl GitLab Cloud
    gle GitLab Enterprise
    bb Bitbucket Cloud
    bbe Bitbucket Server
  • ORGANIZATION: Name of the organization on the Git provider. For example, codacy. You must have admin permissions over the organization on the Git provider.

  • EMAIL#1...N: Email addresses of the people to be added. For example,

Example: Adding people from a file containing emails#

We provide an example Bash script that adds all emails in a text file to Codacy. We suggest that you adapt the script to your specific scenario.

The example script:

  1. Defines the account API token used to authenticate on the Codacy API.
  2. Defines the path and filename of the file containing the email addresses list.
  3. Uses awk and sed to read the email addresses list from a file.
  4. Calls the endpoint addPeopleToOrganization to add a list of email addresses to Codacy.
CODACY_API_TOKEN="<your account API token>"
GIT_PROVIDER="<your Git provider>" # gh, ghe, gl, gle, bb, or bbe
ORGANIZATION="<your organization name>"

EMAILS=`awk -vORS=, '{if(length($1)>0) printf("\"%s\",", $1)}' $FILENAME | sed 's/,$//'`

     -H 'Content-Type: application/json' \
     -H "api-token: $CODACY_API_TOKEN" \
     -d "[$EMAILS]"

Expected format of the file containing the email addresses list:

$ cat emails.txt

See also#

Share your feedback 📢

Did this page help you?

Thanks for the feedback! Is there anything else you'd like to tell us about this page?

We're sorry to hear that. Please let us know what we can improve:

Alternatively, you can create a more detailed issue on our GitHub repository.

Thanks for helping improve the Codacy documentation.

Edit this page on GitHub if you notice something wrong or missing.

If you have a question or need help please contact

Last modified January 25, 2023