---
title: "Refresh File Credentials"
method: PUT
path: "/v2/storage/files/{fileId}/refresh"
tags: ["Files"]
---

# Refresh File Credentials

`PUT /v2/storage/files/{fileId}/refresh`

## Request

- Base URL: `https://connection.keboola.com`
- URL: `https://connection.keboola.com/v2/storage/files/{fileId}/refresh`
- Auth: one of:
  - API key in header `X-StorageApi-Token`
  - API key in header `X-KBC-ManageApiToken`
  - HTTP bearer
- TypeScript: <https://skmtc.dev/keboola/apis/keboola-storage-api/docs/v2/storage/files/:fileId/refresh/put.ts> (a function with typed inputs; its response is checked against the schema)

**Endpoint is used to generate new credentials only for files stored in GCS.**

Because for GCS the maximum lifetime of a credentials are only one hour,
so if in case of longer uploads than one hour we have to generate a new credentials with one hour validity after this time.

**We can generate new credentials up to 12h after the first creation of a file using Create File Resource.**

## Path parameters

- `fileId` integer, required

## Response `200`

File detail with refreshed `gcsUploadParams`.

- FilePrepareResponse
  - `id` integer, required: Identifier of the file.
  - `created` string, required: Creation time of the file, ISO 8601 with a `+hhmm` offset.
  - `isPublic` boolean, required: Whether the file is publicly accessible via a direct URL.
  - `isSliced` boolean, required: Whether the file consists of multiple slices (chunks) described by a manifest file.
  - `isEncrypted` boolean, required: Whether the file content is encrypted in the storage.
  - `name` string, required: Sanitized file name.
  - `fileType` string, required: Human readable file type derived from the file name.
  - `url` string, required: Pre-signed download URL of the file. The URL expires after one hour.
  - `provider` 'aws' | 'azure' | 'gcp', required: File storage provider.
  - `region` string, required: Region of the file storage.
  - `sizeBytes` integer, nullable, required: File size in bytes, null when not known.
  - `tags` string[], required: Tags assigned to the file.
  - `maxAgeDays` integer, nullable, required: Number of days the file is kept before it expires. Null for permanent files.
  - `runId` string, nullable, required: Run ID taken from the X-KBC-RunId header when the file was created.
  - `runIds` string[], required: All run IDs derived from the hierarchical run ID.
  - `creatorToken` object, required: Token that created the file.
    - `id` integer, required
    - `description` string, required
  - `uploadParams` object: Upload parameters. Present only for the `aws` provider.
    - `key` string, required: S3 object key. For sliced files it is the prefix of the slices and of the manifest file.
    - `bucket` string, required: S3 bucket.
    - `acl` 'private' | 'public-read', required: ACL to use for the uploaded object.
    - `credentials` object, required: Temporary AWS credentials with write access to the key.
      - `AccessKeyId` string, required
      - `SecretAccessKey` string, required
      - `SessionToken` string, required
      - `Expiration` string, date-time, required
    - `x-amz-server-side-encryption` string: Present only when `isEncrypted` is true; the encryption header to send with the upload.
  - `absUploadParams` object: Upload parameters. Present only for the `azure` provider.
    - `blobName` string, required
    - `accountName` string, required
    - `container` string, required
    - `absCredentials` object, required: SAS credentials with write access to the container.
      - `SASConnectionString` string, required
      - `expiration` string, required: ISO 8601 with a `+hhmm` offset.
  - `gcsUploadParams` object: Upload parameters. Present only for the `gcp` provider.
    - `projectId` string, required
    - `bucket` string, required
    - `key` string, required
    - `access_token` string, required
    - `expires_in` integer, required: Token lifetime in seconds.
    - `token_type` string, required

## Other responses

- `400`: Returned when the file is not stored in GCS (`storage.refreshFileBackendNotSupported`).
- `404`: Returned when the file does not exist (`storage.files.notFound`).
- `422`: Returned when the file is older than 12 hours (`storage.refreshTimeExceeded`).

---

[API](https://skmtc.dev/keboola/apis/keboola-storage-api.md) - [All operations](https://skmtc.dev/keboola/apis/keboola-storage-api/llms.txt) - [OpenAPI document](https://skmtc.dev/keboola/apis/keboola-storage-api/revisions/34b5ceac0317?raw)
