> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.teekrr.com/llms.txt.
> For full documentation content, see https://docs.teekrr.com/llms-full.txt.

# Upload WhatsApp template header media

POST https://api.teekrr.com/whatsapp/upload-header-image
Content-Type: multipart/form-data

Uploads a header asset (image, video, or document) to Teekrr-managed S3 and
returns its public URL. Use the returned URL in the `variables.headerImage`,
`headerVideo`, or `headerDocument` fields of `POST /whatsapp` and `POST /whatsapp/test`.

**Required scope:** `send_whatsapp`

## Allowed MIME types

| Type | MIME |
| --- | --- |
| Image | `image/jpeg`, `image/png`, `image/webp` |
| Video | `video/mp4` |
| Document | `application/pdf` |

Files outside this set are rejected with `400 Bad Request — Only JPEG, PNG, WebP, MP4, and PDF files are supported`.


Reference: https://docs.teekrr.com/api-reference/whats-app/upload-whatsapp-header

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: Teekrr Public API
  version: 1.0.0
paths:
  /whatsapp/upload-header-image:
    post:
      operationId: upload-whatsapp-header
      summary: Upload WhatsApp template header media
      description: >
        Uploads a header asset (image, video, or document) to Teekrr-managed S3
        and

        returns its public URL. Use the returned URL in the
        `variables.headerImage`,

        `headerVideo`, or `headerDocument` fields of `POST /whatsapp` and `POST
        /whatsapp/test`.


        **Required scope:** `send_whatsapp`


        ## Allowed MIME types


        | Type | MIME |

        | --- | --- |

        | Image | `image/jpeg`, `image/png`, `image/webp` |

        | Video | `video/mp4` |

        | Document | `application/pdf` |


        Files outside this set are rejected with `400 Bad Request — Only JPEG,
        PNG, WebP, MP4, and PDF files are supported`.
      tags:
        - subpackage_whatsApp
      parameters:
        - name: Authorization
          in: header
          description: >
            Bearer API keys are issued from the in-app `/api-management` page.
            Each key has

            a permission scope (`send_sms`, `send_whatsapp`, `send_email`) and
            an optional

            IP whitelist.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: Media uploaded
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/WhatsApp_uploadWhatsappHeader_Response_200
        '400':
          description: Missing file or unsupported MIME type
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Missing, invalid, revoked, or expired API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      requestBody:
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                image:
                  type: string
                  format: binary
                  description: Header media file (JPEG, PNG, WebP, MP4, or PDF)
              required:
                - image
servers:
  - url: https://api.teekrr.com
  - url: https://api.staging.teekrr.com
components:
  schemas:
    WhatsappUploadHeaderImagePostResponsesContentApplicationJsonSchemaData:
      type: object
      properties:
        url:
          type: string
          format: uri
          description: Public URL of the uploaded media
      title: WhatsappUploadHeaderImagePostResponsesContentApplicationJsonSchemaData
    WhatsApp_uploadWhatsappHeader_Response_200:
      type: object
      properties:
        data:
          $ref: >-
            #/components/schemas/WhatsappUploadHeaderImagePostResponsesContentApplicationJsonSchemaData
      title: WhatsApp_uploadWhatsappHeader_Response_200
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
      required:
        - message
      title: ErrorResponse
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >
        Bearer API keys are issued from the in-app `/api-management` page. Each
        key has

        a permission scope (`send_sms`, `send_whatsapp`, `send_email`) and an
        optional

        IP whitelist.

```

## SDK Code Examples

```python WhatsApp_uploadWhatsappHeader_example
import requests

url = "https://api.teekrr.com/whatsapp/upload-header-image"

files = { "image": "open('header-image.jpg', 'rb')" }
headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript WhatsApp_uploadWhatsappHeader_example
const url = 'https://api.teekrr.com/whatsapp/upload-header-image';
const form = new FormData();
form.append('image', 'header-image.jpg');

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 WhatsApp_uploadWhatsappHeader_example
package main

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

func main() {

	url := "https://api.teekrr.com/whatsapp/upload-header-image"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"header-image.jpg\"\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 WhatsApp_uploadWhatsappHeader_example
require 'uri'
require 'net/http'

url = URI("https://api.teekrr.com/whatsapp/upload-header-image")

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=\"image\"; filename=\"header-image.jpg\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n"

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

```java WhatsApp_uploadWhatsappHeader_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.teekrr.com/whatsapp/upload-header-image")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"header-image.jpg\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.teekrr.com/whatsapp/upload-header-image', [
  'multipart' => [
    [
        'name' => 'image',
        'filename' => 'header-image.jpg',
        'contents' => null
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp WhatsApp_uploadWhatsappHeader_example
using RestSharp;

var client = new RestClient("https://api.teekrr.com/whatsapp/upload-header-image");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"image\"; filename=\"header-image.jpg\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift WhatsApp_uploadWhatsappHeader_example
import Foundation

let headers = ["Authorization": "Bearer <token>"]
let parameters = [
  [
    "name": "image",
    "fileName": "header-image.jpg"
  ]
]

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.teekrr.com/whatsapp/upload-header-image")! 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()
```