diff --git a/pages/apis/graphql/graphql_cookbook.md b/pages/apis/graphql/graphql_cookbook.md index cbb4ad49b6..67dc8b40ab 100644 --- a/pages/apis/graphql/graphql_cookbook.md +++ b/pages/apis/graphql/graphql_cookbook.md @@ -650,6 +650,53 @@ mutation UpdateSessionIPAddressPinning { } ``` +### Query the usage API + +Use the Usage API to query your organizations usage by pipeline or test suite +at daily granularity. + +```graphql +query Usage { + organization(slug: "organization-slug") { + id + name + usage( + aggregatedOnFrom: "2023-04-01" + aggregatedOnTo: "2023-05-01" + resource:[JOB_MINUTES, TEST_EXECUTIONS] + ) { + edges { + node { + __typename ... on JobMinutesUsage { + aggregatedOn + seconds + pipeline { + name + id + } + } + } + + node { + __typename ... on TestExecutionsUsage { + Time:aggregatedOn + executions + suite { + name + id + } + } + } + } + pageInfo { + endCursor + hasNextPage + } + } + } +} +``` + ### Create a user, add them to a team, and set user permissions Invite a new user to the organization, add them to a team, and set their role.