How to check for unconfirmed stacks using the API / using a notification policy to alert of unconfirmed stacks.
Last updated: July 14, 2025
This article explains how to use GraphQL queries to search for stacks in specific states, such as failed or unconfirmed. This method is particularly useful for setting up automated notifications or periodic checks for stacks that may be stuck in certain states.
Using the searchStacks Query
To search for stacks in specific states, you can use the searchStacks query with the following structure:
query SearchStacksSuggestionsNew($input: SearchSuggestionsInput!) {
searchStacksSuggestions(input: $input) {
filteredCount
fields {
name
orderable
filterable
type
possibleValuesBoolean {
values
counts
__typename
}
possibleValuesEnum {
values
counts
__typename
}
possibleValuesString {
values
counts
__typename
}
possibleValuesHierarchy {
values {
id
parentId
displayValue
__typename
}
counts
__typename
}
__typename
}
__typename
}
}Query Variables for Different Stack States
The key to searching for specific stack states is in the query variables. Here are examples for searching failed and unconfirmed stacks:
For Unconfirmed Stacks:
{
"input": {
"fullTextSearch": "",
"predicates": [
{
"field": "state",
"exclude": null,
"constraint": {
"enumEquals": [
"UNCONFIRMED"
]
}
}
],
"fields": null
}
}For Failed Stacks:
{
"input": {
"fullTextSearch": "",
"predicates": [
{
"field": "state",
"exclude": null,
"constraint": {
"enumEquals": [
"FAILED"
]
}
}
],
"fields": null
}
}Using the Query Results
You can use these queries to set up automated checks or notifications. For example:
Create a cron job that runs the query periodically and sends alerts for stacks that have been in an unconfirmed or failed state for a certain period.
Integrate with your team's communication tools (e.g., Slack) to send notifications about problematic stacks.
Alternative: Using Notification Policies
While GraphQL queries are useful for periodic checks, you can also use notification policies for immediate alerts when a stack enters a specific state. However, note that for unconfirmed stacks, this will only trigger once when the stack initially enters the unconfirmed state.
To set up a notification policy:
Use the Spacelift Slack integration (if available).
Create a policy that triggers on specific stack states.
Customize the message to include relevant information and mention specific team members if needed.
Example policy (requires Slack integration):
package spacelift
slack[{
"channel_id": "C012344532",
"message": message,
}] {
stack := input.run_updated.stack
run := input.run_updated.run
run.type == "TRACKED"
run.state == "UNCONFIRMED"
message := sprintf("Stack %s is in an unconfirmed state")