# Build Status

The `/Status` endpoint for each Build lets you retrieve the status of that Build. We recommend using this endpoint to poll for the status, rather than the `/Builds` endpoint.

## Status Properties

```json
{"type":"object","refName":"serverless.v1.service.build.build_status","modelName":"serverless_v1_service_build_build_status","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZB[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the Build resource."},"account_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^AC[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the [Account](/docs/iam/api/account) that created the Build resource."},"service_sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZS[0-9a-fA-F]{32}$","nullable":true,"description":"The SID of the Service that the Build resource is associated with."},"status":{"type":"string","enum":["building","completed","failed"],"description":"The status of the Build. Can be: `building`, `completed`, or `failed`.","refName":"build_status_enum_status","modelName":"build_status_enum_status"},"url":{"type":"string","format":"uri","nullable":true,"description":"The absolute URL of the Build Status resource."}}}
```

## Fetch a BuildStatus resource

`GET https://serverless.twilio.com/v1/Services/{ServiceSid}/Builds/{Sid}/Status`

### Path parameters

```json
[{"name":"ServiceSid","in":"path","description":"The SID of the Service to fetch the Build resource from.","schema":{"type":"string"},"required":true},{"name":"Sid","in":"path","description":"The SID of the Build resource to fetch.","schema":{"type":"string","minLength":34,"maxLength":34,"pattern":"^ZB[0-9a-fA-F]{32}$"},"required":true}]
```

Fetch a Status

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function fetchBuildStatus() {
  const buildStatus = await client.serverless.v1
    .services("ServiceSid")
    .builds("ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .buildStatus()
    .fetch();

  console.log(buildStatus.sid);
}

fetchBuildStatus();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

build_status = (
    client.serverless.v1.services("ServiceSid")
    .builds("ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    .build_status()
    .fetch()
)

print(build_status.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.Serverless.V1.Service.Build;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var buildStatus = await BuildStatusResource.FetchAsync(
            pathServiceSid: "ServiceSid", pathSid: "ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

        Console.WriteLine(buildStatus.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.serverless.v1.service.build.BuildStatus;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        BuildStatus buildStatus = BuildStatus.fetcher("ServiceSid", "ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa").fetch();

        System.out.println(buildStatus.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	resp, err := client.ServerlessV1.FetchBuildStatus("ServiceSid",
		"ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$build_status = $twilio->serverless->v1
    ->services("ServiceSid")
    ->builds("ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
    ->buildStatus()
    ->fetch();

print $build_status->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

build_status = @client
               .serverless
               .v1
               .services('ServiceSid')
               .builds('ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
               .build_status
               .fetch

puts build_status.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:serverless:v1:services:builds:status:fetch \
   --service-sid ServiceSid \
   --sid ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
```

```bash
curl -X GET "https://serverless.twilio.com/v1/Services/ServiceSid/Builds/ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Status" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "ZBaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "service_sid": "ServiceSid",
  "status": "completed",
  "url": "https://serverless.twilio.com/v1/Services/ZS00000000000000000000000000000000/Builds/ZB00000000000000000000000000000000/Status"
}
```
