---
title: "Automate your pre-release testing with the App Distribution REST API"
description: "Automate your pre-release testing with the App Distribution REST API"
published: "2021-11-08"
last_updated: "2021-11-08"
authors:
  - "Liat Berry (Product Manager)"
  - "Lee Kellogg (Software Engineer)"
categories:
  - "App Distribution"
  - "Launch"
canonical_url: "https://firebase.blog/posts/2021/11/app-distribution-rest-api"
---

# Automate your pre-release testing with the App Distribution REST API

*Published November 8, 2021 by Liat Berry (Product Manager), Lee Kellogg (Software Engineer)*

---
Getting feedback on your app's releases before they reach the store is critical. [App Distribution](https://firebase.google.com/products/app-distribution) makes it easy to share pre-release builds of your Android and iOS apps with your testers. You can distribute your apps to testers using the Firebase console, the Firebase CLI, or the App Distribution plugins for Gradle and fastlane.

We've also heard that you'd like to integrate your own tools directly with App Distribution, or implement custom pre-release testing workflows. That's where the [Firebase App Distribution REST API](https://firebase.google.com/docs/reference/app-distribution/rest) comes in. With this API, you can build custom logic into your team's tools and services to add and remove testers, upload new app binaries, distribute your releases, update release notes, deleting releases, and more.

For example, let's say that your company gives all employees early access to the latest builds of your app. You also have a personnel management tool that automates the employee onboarding and offboarding process. Wouldn't it be nice if employee access was automatically granted and revoked as employees join and leave your company? With the REST API, you can build this functionality directly into your company's workflow.

Let's walk through the process to automatically grant and revoke access.

### Automating access

#### Authenticate with the API
To access the API, [enable](https://cloud.google.com/apis/docs/getting-started#enabling_apis) the [Firebase App Distribution API](https://console.cloud.google.com/apis/library/firebaseappdistribution.googleapis.com?project=_) for your project and choose a way to [authenticate](https://cloud.google.com/docs/authentication) your integration. In this scenario, download a [service account key](https://cloud.google.com/docs/authentication/production#create_service_account) and use [oath2l](https://github.com/google/oauth2l) to get an access token:

```bash
oauth2l fetch 
  --credentials /path/to/service-account.json 
  --scope https://www.googleapis.com/auth/cloud-platform
```

#### Make HTTP requests to the API
Next, in hooks that are triggered when an employee joins or leaves the company, use the [testers.batchAdd](https://firebase.google.com/docs/reference/app-distribution/rest/v1/projects.testers/batchAdd) and [testers.batchRemove](https://firebase.google.com/docs/reference/app-distribution/rest/v1/projects.testers/batchRemove) endpoints to add or remove the employee as a tester in App Distribution using an HTTP request to the API. For example, here's how you can add a new tester using curl:

```bash
SERVICE=https://firebaseappdistribution.googleapis.com

curl --request POST 
  $SERVICE/v1/projects/[PROJECT_NUMBER]/testers:batchAdd 
  --header 'Authorization: Bearer [ACCESS_TOKEN]' 
  --header 'Accept: application/json' 
  --header 'Content-Type: application/json' 
  --data '{"emails":["newemployee@company.com"]}'
```

Let's say you periodically audit access to your pre-release apps to make sure that only authorized internal testers have access. To automate this audit, you can use the [testers.list](https://firebase.google.com/docs/reference/app-distribution/rest/v1/projects.testers/list) endpoint to get the list of testers in your Firebase project. You can then write your own logic to compare that to your list of employee email addresses, or check the domains:

```bash
curl 
  $SERVICE/v1/projects/[PROJECT_NUMBER]/testers 
  --header 'Authorization: Bearer [ACCESS_TOKEN]' 
  --header 'Accept: application/json'
```

#### Build your own custom workflow
Tester access and auditing is just one example of custom functionality you can build using the API. Other examples of functionality that you can build include keeping release notes in sync with your bug tracking system, fetching details about your most recent release, adding testers to releases from third-party tools, deleting releases in bulk, or fetching test certificate info for your Android app bundle releases.

App Distribution helps you gain confidence in your releases, and the REST API empowers you to integrate pre-release testing into your existing workflows. So get started with the API today! To learn more, and to try out the API using the embedded API Explorer, see the [Firebase App Distribution API](https://firebase.google.com/docs/reference/app-distribution/rest) documentation.

![Try out the API using the API Explorer in the documentation](https://firebasestorage.googleapis.com/v0/b/first-class-blog.appspot.com/o/blog-assets%2F2021%2F11%2Fapp-distribution-rest-api%2Foptimized%2Ffb-blog-automate-your-pre-release-testing-with-the-app-distribution-rest-api.gif?alt=media)
