This guide shows you how to set up your own Amazon Web Services (AWS) or Google Cloud Platform (GCP) storage so that Branch can deliver Scheduled Log Exports data to it. For how the API works, see the overview.
Before you begin
Make sure you have these.
- An Access Token: see Credentials. Its owner needs the Export permission and access to Sensitive Data.
- Permission to create roles and buckets: in the AWS or GCP account that receives the data.
Branch writes the files, deletes the old files in each job's folder before it uploads, and tests your setup when you create the subscription by uploading a small test export of up to 10 rows and then deleting it. So the role or service account needs permission to list, read, create, and delete objects, as the steps below grant.
Cloud configuration
Follow the steps for your cloud provider.
Amazon Web Services
1. Get your external ID from Branch
Send a request to Get an external ID. Use the same app_id or organization_id that you will use to create the subscription, because each one has its own ID. You need this ID in step 5.
2. Create a bucket and a folder
- In S3, create a bucket for your Branch data. Keep it separate from your other buckets, and note its name.
- Create a folder in the bucket. The folder name is the
prefixthat you send when you create the subscription.
3. Create a policy
In the IAM dashboard, go to Policies and select Create policy.
Select the JSON tab, and paste the following. Replace
<bucket_name>with your bucket name and<prefix>with your folder name.json{ "Version": "2012-10-17", "Statement": [ { "Sid": "ListObjectsInBucket", "Effect": "Allow", "Action": ["s3:ListBucket"], "Resource": ["arn:aws:s3:::<bucket_name>"] }, { "Sid": "BranchExportsPut", "Effect": "Allow", "Action": [ "s3:AbortMultipartUpload", "s3:DeleteObject", "s3:GetObject", "s3:ListBucket", "s3:ListBucketMultipartUploads", "s3:ListMultipartUploadParts", "s3:PutObject" ], "Resource": ["arn:aws:s3:::<bucket_name>/<prefix>/*"] } ] }Name the policy, for example
branch-scheduled-log-exports, and select Create policy.
4. Create a role
- In the IAM dashboard, go to Roles and select Create role.
- Choose AWS account as the trusted entity, and select the policy that you created in step 3.
- Include
Branch-Export-Uploadin the role name, for exampleBranch-Export-Upload-Example. Branch only assumes roles whose name contains that text. - Select Create role, open the new role, and note its ARN. It looks like
arn:aws:iam::123456789012:role/Branch-Export-Upload-Example.
5. Let Branch assume the role
On the role, open the Trust relationships tab and select Edit trust policy.
Paste the following. Replace
<external_id>with the ID from step 1.json{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::772300342379:role/BranchTMRoleProdDataPlatformExports" }, "Action": "sts:AssumeRole", "Condition": { "StringEquals": { "sts:ExternalId": "<external_id>" } } } ] }
6. Create the subscription
Send a request to Create a subscription with a report object, as in the example, and these destination fields.
subscription_type:cloudcloud:s3resource_access_id: the role ARN from step 4bucket: your bucket nameprefix: your folder name
7. Check for data
Send a request to Get a subscription until report.subscription_status is ACTIVE. If it's FAILED_VERIFICATION, Branch couldn't write to or delete from your bucket, so check the role name, the trust policy, and the external ID, then create the subscription again.
When jobs run, Branch writes the files in folders inside your prefix. This example is for an hourly subscription.
s3://my-branch-export-bucket/my-folder/subscription_id=1d7d7c2e-175b-11ec-9621-0242ac130002/report_type=eo_install/y=2026/m=11/d=17/h=00/The files use the compression you chose, gz or snappy. Process a folder only after its _SUCCESS file appears.
Google Cloud Platform
1. Get your external ID from Branch
Send a request to Get an external ID. Use the same app_id or organization_id that you will use to create the subscription. You need this ID in step 7.
2. Create two custom roles
Predefined bucket roles give more permissions than Branch needs, so create two roles with fewer permissions.
- In the IAM & Admin dashboard, go to Roles, and make sure the correct project is selected.
- Select Create Role, name it
Branch SLE Object List, and add thestorage.objects.listpermission. - Select Create Role again, name it
Branch SLE Upload, and add these permissions.storage.objects.createstorage.objects.getstorage.objects.delete
3. Create a service account
In the IAM & Admin dashboard, go to Service Accounts, select Create Service Account, and name it, for example branch-sle-service-acct.
4. Let Branch use the service account
- Open the new service account and select the Permissions tab.
- Select Grant Access, and add
gcs-sle-prod-usw1@project-sle-prod.iam.gserviceaccount.comas a principal. - Give that principal the
Service Account Token Creatorrole.
5. Create a bucket and a folder
- In Cloud Storage, create a bucket for your Branch data. Keep it separate from your other buckets.
- Create a folder in the bucket. The folder name is the
prefixthat you send when you create the subscription.
6. Give the service account access to the bucket
- Open the bucket and select the Permissions tab.
- Select Grant Access, and add your service account as a principal.
- Assign the
Branch SLE Object ListandBranch SLE Uploadroles.
7. Limit uploads to Branch's folder
Branch writes files under an external_id=<external ID> folder in your prefix. To let the upload role write only there, add a condition to it.
For the
Branch SLE Uploadrole, select Add IAM condition, and give it a title such asPermit SLE Upload to Bucket.In the Condition Editor tab, enter the following. Replace
<YOUR-BUCKET>,<YOUR-PREFIX>, and<YOUR-EXTERNAL-ID>with your bucket name, your folder path, and the ID from step 1.javascriptresource.name.startsWith("projects/_/buckets/<YOUR-BUCKET>/objects/<YOUR-PREFIX>/external_id=<YOUR-EXTERNAL-ID>/")For example, for the bucket
my-branch-bucket, the prefixbranch/important_reports, and the external ID0a0a0-a0a0a0a-0a0a0a, enterresource.name.startsWith("projects/_/buckets/my-branch-bucket/objects/branch/important_reports/external_id=0a0a0-a0a0a0a-0a0a0a/").
8. Create the subscription
Send a request to Create a subscription with a report object, as in the example, and these destination fields.
subscription_type:cloudcloud:gcsresource_access_id: your service account email, for examplebranch-sle-service-acct@your-sle-project.iam.gserviceaccount.combucket: your bucket name, for examplemy-branch-bucketprefix: your folder path, for examplebranch/important_reports
9. Check for data
Send a request to Get a subscription until report.subscription_status is ACTIVE. If it's FAILED_VERIFICATION, Branch couldn't write to or delete from your bucket, so check the service account roles and the condition, then create the subscription again.
When jobs run, Branch writes the files under <prefix>/external_id=<external ID>/subscription_id=<id>/report_type=<topic>/y=<year>/m=<month>/d=<day>/, plus h=<hour>/ for hourly subscriptions. The files use the compression you chose, gz or snappy. Process a folder only after its _SUCCESS file appears.
