> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# SetPushCredential

POST https://api.voximplant.com/platform_api/SetPushCredential
Content-Type: multipart/form-data

Modifies push credentials.

Allowed roles: `Owner`, `Admin`, `Developer`.

**Example request:** Modify credentials.

Reference: https://docs.voximplant.ai/api-reference/management-api/reference/push-credentials/set-push-credential

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: management-api
  version: 1.0.0
paths:
  /SetPushCredential:
    post:
      operationId: set-push-credential
      summary: SetPushCredential
      description: |-
        Modifies push credentials.

        Allowed roles: `Owner`, `Admin`, `Developer`.

        **Example request:** Modify credentials.
      tags:
        - subpackage_pushCredentials
      parameters:
        - name: push_credential_id
          in: query
          description: The push credentials id
          required: true
          schema:
            type: integer
        - name: cert_password
          in: query
          description: The secret password for private key. Credentials for APPLE push
          required: false
          schema:
            type: string
        - name: is_dev_mode
          in: query
          description: >-
            Whether to use this certificate in apple's sandbox environment.
            Credentials for APPLE push
          required: false
          schema:
            type: boolean
        - name: sender_id
          in: query
          description: The sender id, provided by Google. Credentials for GOOGLE push
          required: false
          schema:
            type: string
        - name: server_key
          in: query
          description: The server key, provided by Google. Credentials for GOOGLE push
          required: false
          schema:
            type: string
        - name: huawei_client_id
          in: query
          description: The client id, provided by Huawei. Credentials for HUAWEI push
          required: false
          schema:
            type: string
        - name: huawei_client_secret
          in: query
          description: The client secret, provided by Huawei. Credentials for HUAWEI push
          required: false
          schema:
            type: string
        - name: huawei_application_id
          in: query
          description: The application id, provided by Huawei. Credentials for HUAWEI push
          required: false
          schema:
            type: string
        - name: Authorization
          in: header
          description: >-
            Voximplant Management API uses signed JWT tokens generated from your
            service-account private key. Pass the token in the `Authorization`
            header as a Bearer value:


            ```

            Authorization: Bearer $VOXIMPLANT_TOKEN

            ```


            See [Authorization](/api-reference/management-api/authorization) for
            ready-to-copy snippets in bash, Python, Node.js and Go that turn
            your `credentials.json` into a token.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/push-credentials_SetPushCredential_Response_200
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                cert_content:
                  type: string
                  format: binary
                  description: >-
                    Public and private keys in PKCS12 format. Credentials for
                    APPLE push
                service_account_file:
                  type: string
                  format: binary
                  description: >-
                    The service account key file, provided by Google. Can be
                    used instead of **server_key**. Credentials for GOOGLE push
servers:
  - url: https://api.voximplant.com/platform_api
components:
  schemas:
    push-credentials_SetPushCredential_Response_200:
      type: object
      properties:
        result:
          type: integer
      title: push-credentials_SetPushCredential_Response_200
  securitySchemes:
    JwtAuth:
      type: http
      scheme: bearer
      description: >-
        Voximplant Management API uses signed JWT tokens generated from your
        service-account private key. Pass the token in the `Authorization`
        header as a Bearer value:


        ```

        Authorization: Bearer $VOXIMPLANT_TOKEN

        ```


        See [Authorization](/api-reference/management-api/authorization) for
        ready-to-copy snippets in bash, Python, Node.js and Go that turn your
        `credentials.json` into a token.

```

## SDK Code Examples

```python Example 1
import requests

url = "https://api.voximplant.com/platform_api/SetPushCredential"

querystring = {"push_credential_id":"1"}

files = {
    "cert_content": "open('<file1>', 'rb')",
    "service_account_file": "open('<file1>', 'rb')"
}
headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, files=files, headers=headers, params=querystring)

print(response.json())
```

```javascript Example 1
const url = 'https://api.voximplant.com/platform_api/SetPushCredential?push_credential_id=1';
const form = new FormData();
form.append('cert_content', '<file1>');
form.append('service_account_file', '<file1>');

const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

options.body = form;

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

```go Example 1
package main

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

func main() {

	url := "https://api.voximplant.com/platform_api/SetPushCredential?push_credential_id=1"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cert_content\"; filename=\"<file1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"service_account_file\"; filename=\"<file1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n")

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

	req.Header.Add("Authorization", "Bearer <token>")

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

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

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

}
```

```ruby Example 1
require 'uri'
require 'net/http'

url = URI("https://api.voximplant.com/platform_api/SetPushCredential?push_credential_id=1")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cert_content\"; filename=\"<file1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"service_account_file\"; filename=\"<file1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n"

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

```java Example 1
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.voximplant.com/platform_api/SetPushCredential?push_credential_id=1")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cert_content\"; filename=\"<file1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"service_account_file\"; filename=\"<file1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n")
  .asString();
```

```php Example 1
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.voximplant.com/platform_api/SetPushCredential?push_credential_id=1', [
  'multipart' => [
    [
        'name' => 'cert_content',
        'filename' => '<file1>',
        'contents' => null
    ],
    [
        'name' => 'service_account_file',
        'filename' => '<file1>',
        'contents' => null
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Example 1
using RestSharp;

var client = new RestClient("https://api.voximplant.com/platform_api/SetPushCredential?push_credential_id=1");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"cert_content\"; filename=\"<file1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"service_account_file\"; filename=\"<file1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Example 1
import Foundation

let headers = ["Authorization": "Bearer <token>"]
let parameters = [
  [
    "name": "cert_content",
    "fileName": "<file1>"
  ],
  [
    "name": "service_account_file",
    "fileName": "<file1>"
  ]
]

let boundary = "---011000010111000001101001"

var body = ""
var error: NSError? = nil
for param in parameters {
  let paramName = param["name"]!
  body += "--\(boundary)\r\n"
  body += "Content-Disposition:form-data; name=\"\(paramName)\""
  if let filename = param["fileName"] {
    let contentType = param["content-type"]!
    let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
    if (error != nil) {
      print(error as Any)
    }
    body += "; filename=\"\(filename)\"\r\n"
    body += "Content-Type: \(contentType)\r\n\r\n"
    body += fileContent
  } else if let paramValue = param["value"] {
    body += "\r\n\r\n\(paramValue)"
  }
}

let request = NSMutableURLRequest(url: NSURL(string: "https://api.voximplant.com/platform_api/SetPushCredential?push_credential_id=1")! 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()
```