# Export Branch stats

_Export branch stats using Avo API_

The Export API gives you the possibility to export your Avo branches as CSV.

## Endpoint

```Url
https://api.avo.app/workspaces/:workspaceId/branches/export/v1
```

`:workspaceId` is the ID of your workspace. You'll find it in the URL of your avo tab after `/schemas/`.

Returns [a CSV string that is a representation of your branch stats for all branches in the workspace]

CSV Headers

- `branchName`: Name of the branch
- `branchId`: Id of the branch
- `branchCreatorId`: userId of the branch creator
- `branchCreatorEmail`: email of the branch creator
- `creationDate`: UTC timestamp when the branch was created
- `branchStatus`: current status on the branch [Merged | Closed | Approved | Draft | ReadyForReview]
- `collaborators`: array of user emails that helped on the branch.
- `lastPublishedDate`: UTC timestamp of last time when the branch was published to a downstream publishing integration
- `markedReadyForReviewDate`: UTC timestamp when the branch was marked as ReadyForReview. This will return the date of the first ReadyForReview event.
- `markedReadyForReviewerUserEmail`: email of the user who marked the branch as ReadyForReview. This will return the email of the user who first marked the branch as ReadyForReview.
- `branchMergedDate`: UTC timestamp when the branch was merged
- `branchMergedUserEmail`: email of the user who merged the branch.

### Authentication

This endpoint requires an [authorization header](https://www.avo.app/docs/reference/public-api/authentication.md#authenticating-with-avo-api) containing a Base64 encoded service account name and secret.

### Rate Limit

We currently soft-enforce 1/req/s rate limit per service account for this endpoint. Please reach out to us if you have a use case in mind that requires a higher rate limit.

## Parameters

### - _workspaceId_

Locate your workspaceId in the URL
`avo.app/schemas/:workspaceId`

### - branchStatuses (optional)

Comma separated list of branch statuses to include in the export, if the parameter is not provided, all branch statuses will be included.

List of branch statuses:

- Merged
- Open
- Closed
- Draft
- ReadyForReview
- ChangesRequested
- Approved

example:

```
branchStatuses=Approved,ReadyForReview
```

### - format (optional)

the format of the response, defaults to csv

options:

- csv
- json

example:

```
format=json
```

#### example request

```sh
curl -X GET https://api.avo.app/workspaces/:workspaceId/branches/export/v1?branchStatuses=Approved,Closed&format=json
```

#### response

```json
{
  "branches": {
    "9I2PVpWpy": {
      "branchId": "9I2PVpWpy",
      "branchName": "branch0",
      "branchCreator": "hi@avo.sh",
      "creationDate": "2024-11-13T12:33:02.491Z",
      "branchStatus": "Closed",
      "collaborators": ["hi@avo.app"],
      "lastPublishedDate": null,
      "markedReadyForReviewDate": null,
      "markedReadyForReviewUser": null,
      "branchMergedDate": null,
      "branchMergedUser": null
    },
    "MjXJOyCW0": {
      "branchId": "MjXJOyCW0",
      "branchName": "branch1",
      "branchCreator": "hi@avo.app",
      "creationDate": "2024-11-13T13:13:32.063Z",
      "branchStatus": "Closed",
      "collaborators": ["hi@avo.app"],
      "lastPublishedDate": null,
      "markedReadyForReviewDate": null,
      "markedReadyForReviewUser": null,
      "branchMergedDate": null,
      "branchMergedUser": null
    },
    "O6ZTDuyrOU": {
      "branchId": "O6ZTDuyrOU",
      "branchName": "branch2",
      "branchCreator": "hi@avo.app",
      "creationDate": "2024-03-12T19:42:15.777Z",
      "branchStatus": "Approved",
      "collaborators": ["hi@avo.app"],
      "lastPublishedDate": null,
      "markedReadyForReviewDate": "2024-03-12T19:42:46.288Z",
      "markedReadyForReviewUser": "hi@avo.app",
      "branchMergedDate": null,
      "branchMergedUser": null
    }
  }
}
```

### - Base64 encoding secret header

The base64 encoded token expects `name:secret`

See more on [authorization](https://www.avo.app/docs/reference/public-api/authentication.md#authenticating-with-avo-api)

### Request

```sh
$ curl -H "authorization: Basic <Base64 encoded token>" -X GET https://api.avo.app/workspaces/:workspaceId/export/v1
```
