# Create Storage Credential

post ` https://app.mk.io/api/v1/projects/:project_name/media/storage/:storage_name/credentials`

Creates a Storage Credential. You can add as many Storage Credentials as you like to a Storage instance.
We will choose the Storage Credential with the longest expiry time when we need to access the Storage instance.
Credentials are immutable once created - but you can create a new Storage Credential record, then delete the old one.

RBAC Capability Required: `infra.storagetoken.create`

## Authentication

Authorization Bearer

Bearer authentication of the form `Bearer <token>`, where token is your
auth token.

## Path parameters

project_name string Required

storage_name string Required

## Request

This endpoint expects an object.

spec object Required

The specification of the credential.

Show 3 variants Hide 3 variants

Discriminated by `type`. Select one variant:

### Microsoft.Storage

object [AzureCredentialSpecCreate](https://docs.mediakind.com/api-reference/media-api/schemas/azurecredentialspeccreate)

credential object [AzureCredentialCreate](https://docs.mediakind.com/api-reference/media-api/schemas/azurecredentialcreate) Required

The credential for the Azure Storage Account

Show 1 property Hide 1 property

- sasToken string Required pattern: ^\?(\[a-z\]+=\[^&\]+)(&\[a-z\]+=\[^&\]+)+$

SAS Token for Azure Storage Account, including leading ?

- type enum or null Required

The type of the credential.

Allowed values: Microsoft.Storage, AWS.S3, Google.Storage

### AWS.S3

object [AWSCredentialSpec](https://docs.mediakind.com/api-reference/media-api/schemas/awscredentialspec)

credential object [AWSCredential](https://docs.mediakind.com/api-reference/media-api/schemas/awscredential) Required

The credential for the AWS S3 bucket.

Show 2 properties Hide 2 properties

- accessKeyId string Required pattern: ^A\[KS\]IA\[0-9A-Z\]{16}$

The access key ID for the bucket.

- secretAccessKey string Required pattern: ^\[A-Za-z0-9+/=\]{40}$

The secret access key for the bucket.

- type enum or null Required

The type of the credential.

Allowed values: Microsoft.Storage, AWS.S3, Google.Storage

### Google.Storage

object [GoogleCredentialSpec](https://docs.mediakind.com/api-reference/media-api/schemas/googlecredentialspec)

credential object [GoogleCredential](https://docs.mediakind.com/api-reference/media-api/schemas/googlecredential) Required

The credential for the Google Storage bucket.

Show 1 property Hide 1 property

- gac map from strings to string Required

Google Application Credentials in JSON format.

You can generate this from the command line with `gcloud iam service-accounts keys create key.json --iam-account=<service_account>@<project>.iam.gserviceaccount.com`

Or download it from the GCP console.

Show value schema Hide value schema

- 
  [any key] string

- type enum or null Required

The type of the credential.

Allowed values: Microsoft.Storage, AWS.S3, Google.Storage

## Response

201 Create a Storage instance Credential.

metadata object [SasTokenMetadataSchema](https://docs.mediakind.com/api-reference/media-api/schemas/sastokenmetadataschema) Required

Metadata about the credential.

Show 7 properties Hide 7 properties

- created string Optional format: date-time

The time when the resource was created

- createdBy string Optional format: uuid

ID of the user who created the resource

- createdByEmail string Optional

Email of the user who created the resource

- id string Required format: uuid

The ID of the resource

- updated string Optional format: date-time

The time when the resource was last updated

- updatedBy string Optional format: uuid

ID of the user who last updated the resource

- updatedByEmail string Optional

Email of the user who last updated the resource

- spec object Required

The specification of the credential.

Show 3 variants Hide 3 variants

Discriminated by `type`. Select one variant:

### Microsoft.Storage

object [AzureCredentialSpecRead](https://docs.mediakind.com/api-reference/media-api/schemas/azurecredentialpecread)

credential object [AzureCredentialRead](https://docs.mediakind.com/api-reference/media-api/schemas/azurecredentialread) Required

The credential for the Azure Storage Account

Show 3 properties Hide 3 properties

- sasToken string Required pattern: ^\?(\[a-z\]+=\[^&\]+)(&\[a-z\]+=\[^&\]+)+$

SAS Token for Azure Storage Account, including leading ?

- signedExpiry string Required format: date-time

The expiry time of the token.

- signedStart string or null Required format: date-time

The start time of the token.

- type enum or null Required

The type of the credential.

Allowed values: Microsoft.Storage, AWS.S3, Google.Storage

### AWS.S3

object [AWSCredentialSpec](https://docs.mediakind.com/api-reference/media-api/schemas/awscredentialspec)

credential object [AWSCredential](https://docs.mediakind.com/api-reference/media-api/schemas/awscredential) Required

The credential for the AWS S3 bucket.

Show 2 properties Hide 2 properties

- accessKeyId string Required pattern: ^A\[KS\]IA\[0-9A-Z\]{16}$

The access key ID for the bucket.

- secretAccessKey string Required pattern: ^\[A-Za-z0-9+/=\]{40}$

The secret access key for the bucket.

- type enum or null Required

The type of the credential.

Allowed values: Microsoft.Storage, AWS.S3, Google.Storage

### Google.Storage

object [GoogleCredentialSpec](https://docs.mediakind.com/api-reference/media-api/schemas/googlecredentialspec)

credential object [GoogleCredential](https://docs.mediakind.com/api-reference/media-api/schemas/googlecredential) Required

The credential for the Google Storage bucket.

Show 1 property Hide 1 property

- gac map from strings to string Required

Google Application Credentials in JSON format.

Or download it from the GCP console.

Show value schema Hide value schema

- 
  [any key] string

- type enum or null Required

The type of the credential.

Allowed values: Microsoft.Storage, AWS.S3, Google.Storage

## Errors

400 Bad Request

error object [ErrorDetail](https://docs.mediakind.com/api-reference/media-api/schemas/errordetail) Required

Pertinent information about the error

Show 3 properties Hide 3 properties

- code string Required

The error code.

- detail string Required

The error message.

- extraDetail map from strings to any Optional

Extra information regarding this error.

Show value schema Hide value schema

- 
  [any key] any

- ref string Required

A reference to the request that caused the error.

- status integer Required

The HTTP status code

401 Unauthorized

error object [ErrorDetail](https://docs.mediakind.com/api-reference/media-api/schemas/errordetail) Required

Pertinent information about the error

Show 3 properties Hide 3 properties

- code string Required

The error code.

- detail string Required

The error message.

- extraDetail map from strings to any Optional

Extra information regarding this error.

Show value schema Hide value schema

- 
  [any key] any

- ref string Required

A reference to the request that caused the error.

- status integer Required

The HTTP status code

403 Forbidden

error object [ErrorDetail](https://docs.mediakind.com/api-reference/media-api/schemas/errordetail) Required

Pertinent information about the error

Show 3 properties Hide 3 properties

- code string Required

The error code.

- detail string Required

The error message.

- extraDetail map from strings to any Optional

Extra information regarding this error.

Show value schema Hide value schema

- 
  [any key] any

- ref string Required

A reference to the request that caused the error.

- status integer Required

The HTTP status code

404 Not Found

error object [ErrorDetail](https://docs.mediakind.com/api-reference/media-api/schemas/errordetail) Required

Pertinent information about the error

Show 3 properties Hide 3 properties

- code string Required

The error code.

- detail string Required

The error message.

- extraDetail map from strings to any Optional

Extra information regarding this error.

Show value schema Hide value schema

- 
  [any key] any

- ref string Required

A reference to the request that caused the error.

- status integer Required

The HTTP status code

429 Too Many Requests

error object [ErrorDetail](https://docs.mediakind.com/api-reference/media-api/schemas/errordetail) Required

Pertinent information about the error

Show 3 properties Hide 3 properties

- code string Required

The error code.

- detail string Required

The error message.

- extraDetail map from strings to any Optional

Extra information regarding this error.

Show value schema Hide value schema

- 
  [any key] any

- ref string Required

A reference to the request that caused the error.

- status integer Required

The HTTP status code

500 Internal Server Error

error object [ErrorDetail](https://docs.mediakind.com/api-reference/media-api/schemas/errordetail) Required

Pertinent information about the error

Show 3 properties Hide 3 properties

- code string Required

The error code.

- detail string Required

The error message.

- extraDetail map from strings to any Optional

Extra information regarding this error.

Show value schema Hide value schema

- 
  [any key] any

- ref string Required

A reference to the request that caused the error.

- status integer Required

The HTTP status code
