REST Resource: sites.versions

Resource: Version

A Version is a configuration and a collection of static files which determine how a site is displayed.

JSON representation
{
  "name": string,
  "status": enum (VersionStatus),
  "config": {
    object (ServingConfig)
  },
  "labels": {
    string: string,
    ...
  },
  "createTime": string,
  "createUser": {
    object (ActingUser)
  },
  "finalizeTime": string,
  "finalizeUser": {
    object (ActingUser)
  },
  "deleteTime": string,
  "deleteUser": {
    object (ActingUser)
  },
  "fileCount": string,
  "versionBytes": string
}
Fields
name

string

The fully-qualified resource name for the version, in the format:

sites/SITE_ID/versions/VERSION_ID

This name is provided in the response body when you call versions.create.

status

enum (VersionStatus)

The deploy status of the version.

For a successful deploy, call versions.create to make a new version (CREATED status), upload all desired files to the version, then update the version to the FINALIZED status.

Note that if you leave the version in the CREATED state for more than 12 hours, the system will automatically mark the version as ABANDONED.

You can also change the status of a version to DELETED by calling versions.delete.

config

object (ServingConfig)

The configuration for the behavior of the site. This configuration exists in the firebase.json file.

labels

map (key: string, value: string)

The labels used for extra metadata and/or filtering.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

createTime

string (Timestamp format)

Output only. The time at which the version was created.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

createUser

object (ActingUser)

Output only. Identifies the user who created the version.

finalizeTime

string (Timestamp format)

Output only. The time at which the version was FINALIZED.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

finalizeUser

object (ActingUser)

Output only. Identifies the user who FINALIZED the version.

deleteTime

string (Timestamp format)

Output only. The time at which the version was DELETED.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

deleteUser

object (ActingUser)

Output only. Identifies the user who DELETED the version.

fileCount

string (int64 format)

Output only. The total number of files associated with the version.

This value is calculated after a version is FINALIZED.

versionBytes

string (int64 format)

Output only. The total stored bytesize of the version.

This value is calculated after a version is FINALIZED.

VersionStatus

The current known status of a specific version in the deploy lifecycle.

Enums
VERSION_STATUS_UNSPECIFIED The default status; should not be intentionally used.
CREATED The version has been created, and content is currently being added to the version.
FINALIZED All content has been added to the version, and the version can no longer be changed.
DELETED The version has been deleted.
ABANDONED The version was not updated to FINALIZED within 12 hours and was automatically deleted.
EXPIRED The version is outside the site-configured limit for the number of retained versions, so the version's content is scheduled for deletion.
CLONING The version is being cloned from another version. All content is still being copied over.

ServingConfig

The configuration for how incoming requests to a site should be routed and processed before serving content. The URL request paths are matched against the specified URL patterns in the configuration, then Hosting applies the applicable configuration according to a specific priority order.

JSON representation
{
  "headers": [
    {
      object (Header)
    }
  ],
  "redirects": [
    {
      object (Redirect)
    }
  ],
  "rewrites": [
    {
      object (Rewrite)
    }
  ],
  "cleanUrls": boolean,
  "trailingSlashBehavior": enum (TrailingSlashBehavior),
  "i18n": {
    object (I18nConfig)
  }
}
Fields
headers[]

object (Header)

An array of objects, where each object specifies a URL pattern that, if matched to the request URL path, triggers Hosting to apply the specified custom response headers.

redirects[]

object (Redirect)

An array of objects (called redirect rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond with a redirect to the specified destination path.

rewrites[]

object (Rewrite)

An array of objects (called rewrite rules), where each rule specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond as if the service were given the specified destination URL.

cleanUrls

boolean

Defines whether to drop the file extension from uploaded files.

trailingSlashBehavior

enum (TrailingSlashBehavior)

Defines how to handle a trailing slash in the URL path.

i18n

object (I18nConfig)

Optional. Defines i18n rewrite behavior.

A Header specifies a URL pattern that, if matched to the request URL path, triggers Hosting to apply the specified custom response headers.

JSON representation
{
  "headers": {
    string: string,
    ...
  },

  // Union field pattern can be only one of the following:
  "glob": string,
  "regex": string
  // End of list of possible types for union field pattern.
}
Fields
headers

map (key: string, value: string)

Required. The additional headers to add to the response.

An object containing a list of "key": value pairs. Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.

Union field pattern.
Required. A string URL pattern to match against the request URL path to determine whether to apply this custom response header. Can be either a Bash-style glob or a RE2 regular expression.

pattern can be only one of the following:
glob

string

The user-supplied glob to match against the request URL path.

regex

string

The user-supplied RE2 regular expression to match against the request URL path.

Redirect

A Redirect specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond with a redirect to the specified destination path.

JSON representation
{
  "statusCode": integer,
  "location": string,

  // Union field pattern can be only one of the following:
  "glob": string,
  "regex": string
  // End of list of possible types for union field pattern.
}
Fields
statusCode

integer

Required. The status HTTP code to return in the response. It must be a valid 3xx status code.

location

string

Required. The value to put in the HTTP location header of the response.

The location can contain capture group values from the pattern using a : prefix to identify the segment and an optional * to capture the rest of the URL. For example:

"glob": "/:capture*",
"statusCode": 301,
"location": "https://example.com/foo/:capture"

Union field pattern.
Required. A string URL pattern to match against the request URL path to determine whether to apply this redirect. Can be either a Bash-style glob or a RE2 regular expression.

pattern can be only one of the following:
glob

string

The user-supplied glob to match against the request URL path.

regex

string

The user-supplied RE2 regular expression to match against the request URL path.

Rewrite

A Rewrite specifies a URL pattern that, if matched to the request URL path, triggers Hosting to respond as if the service were given the specified destination URL.

JSON representation
{
  "functionRegion": string,

  // Union field pattern can be only one of the following:
  "glob": string,
  "regex": string
  // End of list of possible types for union field pattern.

  // Union field behavior can be only one of the following:
  "path": string,
  "function": string,
  "run": {
    object (CloudRunRewrite)
  }
  // End of list of possible types for union field behavior.
}
Fields
functionRegion

string

Optional. Specify a Cloud region for rewritten Functions invocations. If not provided, defaults to us-central1.

Union field pattern.
Required. A string URL pattern to match against the request URL path to determine whether to apply this rewrite. Can be either a Bash-style glob or a RE2 regular expression.

pattern can be only one of the following:
glob

string

The user-supplied glob to match against the request URL path.

regex

string

The user-supplied RE2 regular expression to match against the request URL path.

Union field behavior.
Required. The behavior of the rewrite.

behavior can be only one of the following:
path

string

The URL path to rewrite the request to.

function

string

The function to proxy requests to. Must match the exported function name exactly.

run

object (CloudRunRewrite)

The request will be forwarded to Cloud Run.

CloudRunRewrite

A configured rewrite that directs requests to a Cloud Run service. If the Cloud Run service does not exist when setting or updating your Firebase Hosting configuration, then the request fails. Any errors from the Cloud Run service are passed to the end user (for example, if you delete a service, any requests directed to that service receive a 404 error).

JSON representation
{
  "serviceId": string,
  "region": string,
  "tag": string
}
Fields
serviceId

string

Required. User-defined ID of the Cloud Run service.

region

string

Optional. User-provided region where the Cloud Run service is hosted.

Defaults to us-central1 if not supplied.

tag

string

Optional. User-provided TrafficConfig tag to send traffic to.

When omitted, traffic is sent to the service-wide URI

TrailingSlashBehavior

Defines whether a trailing slash should be added or removed from the request URL path.

Enums
TRAILING_SLASH_BEHAVIOR_UNSPECIFIED

No behavior is specified.

Files are served at their exact location only, and trailing slashes are only added to directory indexes.

ADD Trailing slashes are added to directory indexes as well as to any URL path not ending in a file extension.
REMOVE Trailing slashes are removed from directory indexes as well as from any URL path not ending in a file extension.

I18nConfig

If provided, i18n rewrites are enabled.

JSON representation
{
  "root": string
}
Fields
root

string

Required. The user-supplied path where country and language specific content will be looked for within the public directory.

Methods

clone

Creates a new version on the specified target site using the content of the specified version.

create

Creates a new version for the specified site.

delete

Deletes the specified version.

get

Get the specified version that has been created for the specified site.

list

Lists the versions that have been created for the specified site.

patch

Updates the specified metadata for the specified version.

populateFiles

Adds content files to the specified version.