Best way to query for a release by a tag value in v5 API?

I am using the V5 API and I want to be able to get releases (really just 1) by a value in a tag attached to it. Looking over the API docs I’m not sure there is a straightforward way of doing this. Any ideas?

Hi @jchoate2 - welcome to the forums!

The following javascript snippet demonstrates how to retrieve a release with a tag of foo=bar. Additionally if you only want one you can add &$top=1 to the query:

const fetch = require('node-fetch')

const JWT_TOKEN = "YOUR_TOKEN";

const APP_ID = 1234;

const main = async () => {
    const resourceURL = "https://api.balena-cloud.com/v5/release";
    const filter = `belongs_to__application eq ${APP_ID} and release_tag/any(t:t/tag_key eq 'foo' and t/value eq 'bar')`

    const response = await fetch(`${resourceURL}?$filter=${filter}`, {
        headers: {
            "Authorization": `Bearer ${JWT_TOKEN}`,
        }
    });

    console.log(await response.json())
}

main()

Hope that helps!

Cheers,
James.