> This page is for mk.io.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://mediakind.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://mediakind.ferndocs.com/_mcp/server.

# Create Storage Credential

POST https://app.mk.io/api/v1/projects/{project_name}/media/storage/{storage_name}/credentials
Content-Type: application/json

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`

Reference: https://mediakind.ferndocs.com/mkio/api/media/storage/create-storage-credential

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Path parameters

- `project_name` (string, required)
- `storage_name` (string, required)

### Body (application/json)

This endpoint expects a CredentialSchemaPost.

- `spec` (CredentialSchemaPostSpec, required) — The specification of the credential.

## Response

### 201

Create a Storage instance Credential.

- `metadata` (SasTokenMetadataSchema, required) — Metadata about the credential.
- `spec` (CredentialSchemaGetSpec, required) — The specification of the credential.

## Errors

### 400 Bad Request Error

Bad Request

- `error` (ErrorDetail, required) — Pertinent information about the error
- `ref` (string, required) — A reference to the request that caused the error.
- `status` (integer, required) — The HTTP status code

### 401 Unauthorized Error

Unauthorized

- `error` (ErrorDetail, required) — Pertinent information about the error
- `ref` (string, required) — A reference to the request that caused the error.
- `status` (integer, required) — The HTTP status code

### 403 Forbidden Error

Forbidden

- `error` (ErrorDetail, required) — Pertinent information about the error
- `ref` (string, required) — A reference to the request that caused the error.
- `status` (integer, required) — The HTTP status code

### 404 Not Found Error

Not Found

- `error` (ErrorDetail, required) — Pertinent information about the error
- `ref` (string, required) — A reference to the request that caused the error.
- `status` (integer, required) — The HTTP status code

### 429 Too Many Requests Error

Too Many Requests

- `error` (ErrorDetail, required) — Pertinent information about the error
- `ref` (string, required) — A reference to the request that caused the error.
- `status` (integer, required) — The HTTP status code

### 500 Internal Server Error

Internal Server Error

- `error` (ErrorDetail, required) — Pertinent information about the error
- `ref` (string, required) — A reference to the request that caused the error.
- `status` (integer, required) — The HTTP status code

## Types

### CredentialSchemaPostSpec

The specification of the credential.

- `type`: `AWS.S3` (AWSCredentialSpec)
  - `credential` (AWSCredential, required) — The credential for the AWS S3 bucket.
- `type`: `Google.Storage` (GoogleCredentialSpec)
  - `credential` (GoogleCredential, required) — The credential for the Google Storage bucket.
- `type`: `Microsoft.Storage` (AzureCredentialSpecCreate)
  - `credential` (AzureCredentialCreate, required) — The credential for the Azure Storage Account

### SasTokenMetadataSchema

- `id` (string, required) — The ID of the resource
- `created` (datetime, optional) — The time when the resource was created
- `createdBy` (string, optional) — ID of the user who created the resource
- `createdByEmail` (string, optional) — Email of the user who created the resource
- `updated` (datetime, optional) — The time when the resource was last updated
- `updatedBy` (string, optional) — ID of the user who last updated the resource
- `updatedByEmail` (string, optional) — Email of the user who last updated the resource

### CredentialSchemaGetSpec

The specification of the credential.

- `type`: `AWS.S3` (AWSCredentialSpec)
  - `credential` (AWSCredential, required) — The credential for the AWS S3 bucket.
- `type`: `Google.Storage` (GoogleCredentialSpec)
  - `credential` (GoogleCredential, required) — The credential for the Google Storage bucket.
- `type`: `Microsoft.Storage` (AzureCredentialSpecRead)
  - `credential` (AzureCredentialRead, required) — The credential for the Azure Storage Account

### ErrorDetail

- `code` (string, required) — The error code.
- `detail` (string, required) — The error message.
- `extraDetail` (map from string to any, optional) — Extra information regarding this error.

### AWSCredential

- `accessKeyId` (string, required) — The access key ID for the bucket.
- `secretAccessKey` (string, required) — The secret access key for the bucket.

### GoogleCredential

- `gac` (map from string 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.

### AzureCredentialCreate

- `sasToken` (string, required) — SAS Token for Azure Storage Account, including leading ?

### AzureCredentialRead

- `sasToken` (string, required) — SAS Token for Azure Storage Account, including leading ?
- `signedExpiry` (datetime, required) — The expiry time of the token.
- `signedStart` (datetime, required, nullable) — The start time of the token.

## Examples

### Add AWS credential

**Request**

```json
{
  "spec": {
    "type": "AWS.S3",
    "credential": {
      "accessKeyId": "AKIAEXAMPLE123456789",
      "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
    }
  }
}
```

**Response**

```json
{
  "metadata": {
    "id": "string",
    "created": "2024-01-15T09:30:00Z",
    "createdBy": "string",
    "createdByEmail": "string",
    "updated": "2024-01-15T09:30:00Z",
    "updatedBy": "string",
    "updatedByEmail": "string"
  },
  "spec": {
    "type": "Microsoft.Storage",
    "credential": {
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>",
      "signedExpiry": "2024-11-12T00:05:04Z",
      "signedStart": "2024-11-11T16:05:04Z"
    }
  }
}
```

**SDK Code**

```python Add AWS credential
import requests

url = "https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials"

payload = { "spec": {
        "type": "AWS.S3",
        "credential": {
            "accessKeyId": "AKIAEXAMPLE123456789",
            "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
            "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
        }
    } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Add AWS credential
const url = 'https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"spec":{"type":"AWS.S3","credential":{"accessKeyId":"AKIAEXAMPLE123456789","secretAccessKey":"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY","sasToken":"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Add AWS credential
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials"

	payload := strings.NewReader("{\n  \"spec\": {\n    \"type\": \"AWS.S3\",\n    \"credential\": {\n      \"accessKeyId\": \"AKIAEXAMPLE123456789\",\n      \"secretAccessKey\": \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Add AWS credential
require 'uri'
require 'net/http'

url = URI("https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"spec\": {\n    \"type\": \"AWS.S3\",\n    \"credential\": {\n      \"accessKeyId\": \"AKIAEXAMPLE123456789\",\n      \"secretAccessKey\": \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Add AWS credential
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"spec\": {\n    \"type\": \"AWS.S3\",\n    \"credential\": {\n      \"accessKeyId\": \"AKIAEXAMPLE123456789\",\n      \"secretAccessKey\": \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}")
  .asString();
```

```php Add AWS credential
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials', [
  'body' => '{
  "spec": {
    "type": "AWS.S3",
    "credential": {
      "accessKeyId": "AKIAEXAMPLE123456789",
      "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Add AWS credential
using RestSharp;

var client = new RestClient("https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"spec\": {\n    \"type\": \"AWS.S3\",\n    \"credential\": {\n      \"accessKeyId\": \"AKIAEXAMPLE123456789\",\n      \"secretAccessKey\": \"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\",\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Add AWS credential
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["spec": [
    "type": "AWS.S3",
    "credential": [
      "accessKeyId": "AKIAEXAMPLE123456789",
      "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY",
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Add Azure credential

**Request**

```json
{
  "spec": {
    "type": "Microsoft.Storage",
    "credential": {
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
    }
  }
}
```

**Response**

```json
{
  "metadata": {
    "id": "string",
    "created": "2024-01-15T09:30:00Z",
    "createdBy": "string",
    "createdByEmail": "string",
    "updated": "2024-01-15T09:30:00Z",
    "updatedBy": "string",
    "updatedByEmail": "string"
  },
  "spec": {
    "type": "Microsoft.Storage",
    "credential": {
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>",
      "signedExpiry": "2024-11-12T00:05:04Z",
      "signedStart": "2024-11-11T16:05:04Z"
    }
  }
}
```

**SDK Code**

```python Add Azure credential
import requests

url = "https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials"

payload = { "spec": {
        "type": "Microsoft.Storage",
        "credential": { "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>" }
    } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Add Azure credential
const url = 'https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"spec":{"type":"Microsoft.Storage","credential":{"sasToken":"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Add Azure credential
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials"

	payload := strings.NewReader("{\n  \"spec\": {\n    \"type\": \"Microsoft.Storage\",\n    \"credential\": {\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Add Azure credential
require 'uri'
require 'net/http'

url = URI("https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"spec\": {\n    \"type\": \"Microsoft.Storage\",\n    \"credential\": {\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Add Azure credential
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"spec\": {\n    \"type\": \"Microsoft.Storage\",\n    \"credential\": {\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}")
  .asString();
```

```php Add Azure credential
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials', [
  'body' => '{
  "spec": {
    "type": "Microsoft.Storage",
    "credential": {
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Add Azure credential
using RestSharp;

var client = new RestClient("https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"spec\": {\n    \"type\": \"Microsoft.Storage\",\n    \"credential\": {\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Add Azure credential
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["spec": [
    "type": "Microsoft.Storage",
    "credential": ["sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Add Google credential

**Request**

```json
{
  "spec": {
    "type": "Google.Storage",
    "credential": {
      "gac": {
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "client_email": "sa@mygcpproject.iam.gserviceaccount.com",
        "client_id": "123456789012345678901",
        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/sa%40mygcpproject.iam.gserviceaccount.com",
        "private_key": "-----BEGIN PRIVATE KEY-----\nVGhpcyBpcyBwcml2YXRlIGtleSBpbmZvLgo=\n-----END PRIVATE KEY-----\n",
        "private_key_id": "4a3aeda866dc4f21b6824c882d886009",
        "project_id": "mygcpproject",
        "token_uri": "https://oauth2.googleapis.com/token",
        "type": "service_account"
      },
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
    }
  }
}
```

**Response**

```json
{
  "metadata": {
    "id": "string",
    "created": "2024-01-15T09:30:00Z",
    "createdBy": "string",
    "createdByEmail": "string",
    "updated": "2024-01-15T09:30:00Z",
    "updatedBy": "string",
    "updatedByEmail": "string"
  },
  "spec": {
    "type": "Microsoft.Storage",
    "credential": {
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>",
      "signedExpiry": "2024-11-12T00:05:04Z",
      "signedStart": "2024-11-11T16:05:04Z"
    }
  }
}
```

**SDK Code**

```python Add Google credential
import requests

url = "https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials"

payload = { "spec": {
        "type": "Google.Storage",
        "credential": {
            "gac": {
                "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
                "auth_uri": "https://accounts.google.com/o/oauth2/auth",
                "client_email": "sa@mygcpproject.iam.gserviceaccount.com",
                "client_id": "123456789012345678901",
                "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/sa%40mygcpproject.iam.gserviceaccount.com",
                "private_key": "-----BEGIN PRIVATE KEY-----
VGhpcyBpcyBwcml2YXRlIGtleSBpbmZvLgo=
-----END PRIVATE KEY-----
",
                "private_key_id": "4a3aeda866dc4f21b6824c882d886009",
                "project_id": "mygcpproject",
                "token_uri": "https://oauth2.googleapis.com/token",
                "type": "service_account"
            },
            "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
        }
    } }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript Add Google credential
const url = 'https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"spec":{"type":"Google.Storage","credential":{"gac":{"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","auth_uri":"https://accounts.google.com/o/oauth2/auth","client_email":"sa@mygcpproject.iam.gserviceaccount.com","client_id":"123456789012345678901","client_x509_cert_url":"https://www.googleapis.com/robot/v1/metadata/x509/sa%40mygcpproject.iam.gserviceaccount.com","private_key":"-----BEGIN PRIVATE KEY-----\nVGhpcyBpcyBwcml2YXRlIGtleSBpbmZvLgo=\n-----END PRIVATE KEY-----\n","private_key_id":"4a3aeda866dc4f21b6824c882d886009","project_id":"mygcpproject","token_uri":"https://oauth2.googleapis.com/token","type":"service_account"},"sasToken":"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"}}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Add Google credential
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials"

	payload := strings.NewReader("{\n  \"spec\": {\n    \"type\": \"Google.Storage\",\n    \"credential\": {\n      \"gac\": {\n        \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n        \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n        \"client_email\": \"sa@mygcpproject.iam.gserviceaccount.com\",\n        \"client_id\": \"123456789012345678901\",\n        \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/sa%40mygcpproject.iam.gserviceaccount.com\",\n        \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nVGhpcyBpcyBwcml2YXRlIGtleSBpbmZvLgo=\\n-----END PRIVATE KEY-----\\n\",\n        \"private_key_id\": \"4a3aeda866dc4f21b6824c882d886009\",\n        \"project_id\": \"mygcpproject\",\n        \"token_uri\": \"https://oauth2.googleapis.com/token\",\n        \"type\": \"service_account\"\n      },\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Add Google credential
require 'uri'
require 'net/http'

url = URI("https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"spec\": {\n    \"type\": \"Google.Storage\",\n    \"credential\": {\n      \"gac\": {\n        \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n        \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n        \"client_email\": \"sa@mygcpproject.iam.gserviceaccount.com\",\n        \"client_id\": \"123456789012345678901\",\n        \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/sa%40mygcpproject.iam.gserviceaccount.com\",\n        \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nVGhpcyBpcyBwcml2YXRlIGtleSBpbmZvLgo=\\n-----END PRIVATE KEY-----\\n\",\n        \"private_key_id\": \"4a3aeda866dc4f21b6824c882d886009\",\n        \"project_id\": \"mygcpproject\",\n        \"token_uri\": \"https://oauth2.googleapis.com/token\",\n        \"type\": \"service_account\"\n      },\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java Add Google credential
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"spec\": {\n    \"type\": \"Google.Storage\",\n    \"credential\": {\n      \"gac\": {\n        \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n        \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n        \"client_email\": \"sa@mygcpproject.iam.gserviceaccount.com\",\n        \"client_id\": \"123456789012345678901\",\n        \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/sa%40mygcpproject.iam.gserviceaccount.com\",\n        \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nVGhpcyBpcyBwcml2YXRlIGtleSBpbmZvLgo=\\n-----END PRIVATE KEY-----\\n\",\n        \"private_key_id\": \"4a3aeda866dc4f21b6824c882d886009\",\n        \"project_id\": \"mygcpproject\",\n        \"token_uri\": \"https://oauth2.googleapis.com/token\",\n        \"type\": \"service_account\"\n      },\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}")
  .asString();
```

```php Add Google credential
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials', [
  'body' => '{
  "spec": {
    "type": "Google.Storage",
    "credential": {
      "gac": {
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "client_email": "sa@mygcpproject.iam.gserviceaccount.com",
        "client_id": "123456789012345678901",
        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/sa%40mygcpproject.iam.gserviceaccount.com",
        "private_key": "-----BEGIN PRIVATE KEY-----\\nVGhpcyBpcyBwcml2YXRlIGtleSBpbmZvLgo=\\n-----END PRIVATE KEY-----\\n",
        "private_key_id": "4a3aeda866dc4f21b6824c882d886009",
        "project_id": "mygcpproject",
        "token_uri": "https://oauth2.googleapis.com/token",
        "type": "service_account"
      },
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
    }
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp Add Google credential
using RestSharp;

var client = new RestClient("https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"spec\": {\n    \"type\": \"Google.Storage\",\n    \"credential\": {\n      \"gac\": {\n        \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n        \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n        \"client_email\": \"sa@mygcpproject.iam.gserviceaccount.com\",\n        \"client_id\": \"123456789012345678901\",\n        \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/sa%40mygcpproject.iam.gserviceaccount.com\",\n        \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nVGhpcyBpcyBwcml2YXRlIGtleSBpbmZvLgo=\\n-----END PRIVATE KEY-----\\n\",\n        \"private_key_id\": \"4a3aeda866dc4f21b6824c882d886009\",\n        \"project_id\": \"mygcpproject\",\n        \"token_uri\": \"https://oauth2.googleapis.com/token\",\n        \"type\": \"service_account\"\n      },\n      \"sasToken\": \"?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>\"\n    }\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Add Google credential
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["spec": [
    "type": "Google.Storage",
    "credential": [
      "gac": [
        "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
        "auth_uri": "https://accounts.google.com/o/oauth2/auth",
        "client_email": "sa@mygcpproject.iam.gserviceaccount.com",
        "client_id": "123456789012345678901",
        "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/sa%40mygcpproject.iam.gserviceaccount.com",
        "private_key": "-----BEGIN PRIVATE KEY-----
VGhpcyBpcyBwcml2YXRlIGtleSBpbmZvLgo=
-----END PRIVATE KEY-----
",
        "private_key_id": "4a3aeda866dc4f21b6824c882d886009",
        "project_id": "mygcpproject",
        "token_uri": "https://oauth2.googleapis.com/token",
        "type": "service_account"
      ],
      "sasToken": "?sv=2022-11-02&ss=bfqt&srt=co&sp=rwdlacupiyx&se=2024-11-12T00:05:04Z&st=2024-11-11T16:05:04Z&spr=https&sig=<redacted>"
    ]
  ]] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://app.mk.io/api/v1/projects/project_name/media/storage/storage_name/credentials")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```