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

# Upload Template

POST https://api.taktoria.com/api/v1/meme-templates/upload
Content-Type: multipart/form-data

Add a background by sending the picture itself, as multipart/form-data.

`createTemplate` takes an address, which assumes the caller already has
somewhere to serve the file from. A script pulling pictures out of a
shared drive does not. The image's dimensions are read from the file,
so they do not need to be supplied.

It joins the library unless sent `curate=false`, so by default it is
a key's, which acts with an app admin's rights, or the session of an
app admin of Memegen; anybody else's session is `403 admin_required`. With
`curate=false` it is a background for one meme, which anybody but a
Viewer of Memegen (`403 viewer_only`) may upload, as in the app and
through MCP, and stays out of the picker.
Each upload is a new template; its slug comes from its name,
numbered (`-2`, `-3`…) if it clashes.

Reference: https://docs.taktoria.com/api-reference/memegen/upload-template

## Authentication

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

## Servers

- `https://api.taktoria.com/api/v1` (Production, default)
- `http://localhost:3000/api/v1` (Local)

## Request

### Body (multipart/form-data)

This endpoint expects a multipart form containing a file.

- `file` (file, required)
- `name` (string, optional) — Folded onto one line, trimmed and cut at 120 characters. Left out or blank, the file name, made presentable.
- `layout` (enum, optional)
- `curate` (boolean, optional) — `true` or `false`. Left out, `true`: into the library, an app admin's or a key's. `false`: a background for one meme, anybody's but a Viewer's. Anything else is `422`.

## Response

### 200

- `id` (string, required)
- `organizationId` (string, required)
- `name` (string, required)
- `slug` (string, required)
- `layout` (enum, required) — Where the captions sit on a template.
  - Allowed values: `CAPTION`, `TOP_BOTTOM`, `THREE_PANEL`, `SPLIT`
- `curated` (boolean, required) — Part of the library the workspace curates, rather than a background somebody found while composing one meme. Only curated templates appear in the picker.
- `archived` (boolean, required) — Out of the picker. Memes already made from it keep rendering, which is why a template is archived rather than deleted, but no new meme can be made from it. Only an app admin of Memegen, or a key, brings one back: `archived: false` on `PATCH`, or adding its picture again with `POST /meme-templates`, `/meme-templates/from-url` or `/meme-templates/import`, which restores it. Anybody else who adds the same picture again is refused ("An admin removed this template.") and it stays archived.
- `sortOrder` (integer, required)
- `createdAt` (datetime, required)
- `updatedAt` (datetime, required)
- `builtinKey` (string, optional) — Set on the templates that ship with the app.
- `imageUrl` (string, optional) — The background, an http or https address. Absent on a built-in, which the app draws itself.
- `width` (integer, optional) — The background's real pixel size, so the canvas can match the picture instead of cropping it into a fixed box.
- `height` (integer, optional)
- `attribution` (string, optional) — Where a searched template came from. The background is served from there rather than copied, so the credit stays with the row.
- `sourceUrl` (string, optional) — Where the credit links to, an http or https address.

## Errors

### 402 Subscription Required Error

The organization has no subscription for the app that lets it in: active, trialing or past due. One that is unpaid (Stripe stopped retrying a failed payment), paused, incomplete or cancelled answers this too, and the message says which: an unpaid app is locked until a workspace admin updates the payment details. `details.status` is the app's subscription status (null with none), and `details.paymentIssue` is `unpaid`, or `payment_failed` for an incomplete one whose first payment failed, as `paymentIssue` on `GET /subscription` reckons it; null when a payment is not why.

- `error` (ErrorDetail, required)

### 403 Forbidden Error

Refused, and `error.code` says why. On an app's write endpoints, a signed-in session is refused `viewer_only` when the person is a Viewer of the app (they read it, and change nothing in it), and `seat_required` without a seat on it; a key is never either. Beyond those: `admin_required` when the change is an admin's (an app admin's for an app's admin powers, a workspace admin's for the workspace's settings), `forbidden` when the person may not change this one thing, `read_only_session` for a change only a key makes, `person_required` for what only a signed-in person does through their own account elsewhere (exporting a LaunchCal artifact to their docs tool), which a key cannot, `insufficient_scope` for a key without the scope, and `google_sign_in_required` for a session the workspace's Google rule turns away. Nothing was done.

- `error` (ErrorDetail, required)

### 422 Validation Error

- `error` (ErrorDetail, required)

### 429 Too Many Requests Error

Rate limited (`rate_limited`): the key, the signed-in person, the workspace or an expensive endpoint's own budget is used up for now. `Retry-After` says how many seconds to wait, and `details` names the `policy`, its `limit`, `windowSeconds` and `retryAfter`. Every answer to an authenticated request carries the IETF `RateLimit-Policy` and `RateLimit` headers, so a client can slow down before it gets this. Nothing was done; wait and send it again. See "Rate limits".

- `error` (ErrorDetail, required)

## Types

### ErrorDetail

- `code` (string, required) — A stable machine-readable code such as `not_found`.
- `message` (string, required)
- `details` (any, optional)

## Examples

**Request**

```json
{
  "file": "<file: <filename1>>"
}
```

**Response**

```json
{
  "id": "string",
  "organizationId": "string",
  "name": "string",
  "slug": "string",
  "layout": "CAPTION",
  "curated": true,
  "archived": true,
  "sortOrder": 0,
  "createdAt": "2023-01-01T00:00:00Z",
  "updatedAt": "2023-01-01T00:00:00Z",
  "builtinKey": "string",
  "imageUrl": "string",
  "width": 0,
  "height": 0,
  "attribution": "string",
  "sourceUrl": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.taktoria.com/api/v1/meme-templates/upload"

files = { "file": "open('<filename1>', 'rb')" }
payload = {
    "name": ,
    "layout": ,
    "curate": 
}
headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript
const url = 'https://api.taktoria.com/api/v1/meme-templates/upload';
const form = new FormData();
form.append('file', '<filename1>');
form.append('name', '');
form.append('layout', '');
form.append('curate', '');

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

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

func main() {

	url := "https://api.taktoria.com/api/v1/meme-templates/upload"

	payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"<filename1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"layout\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"curate\"\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
require 'uri'
require 'net/http'

url = URI("https://api.taktoria.com/api/v1/meme-templates/upload")

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=\"file\"; filename=\"<filename1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"layout\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"curate\"\r\n\r\n\r\n-----011000010111000001101001--\r\n"

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

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

HttpResponse<String> response = Unirest.post("https://api.taktoria.com/api/v1/meme-templates/upload")
  .header("Authorization", "Bearer <token>")
  .body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"<filename1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"layout\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"curate\"\r\n\r\n\r\n-----011000010111000001101001--\r\n")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.taktoria.com/api/v1/meme-templates/upload', [
  'multipart' => [
    [
        'name' => 'file',
        'filename' => '<filename1>',
        'contents' => null
    ]
  ]
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.taktoria.com/api/v1/meme-templates/upload");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddParameter("undefined", "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"<filename1>\"\r\nContent-Type: application/octet-stream\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"name\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"layout\"\r\n\r\n\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"curate\"\r\n\r\n\r\n-----011000010111000001101001--\r\n", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <token>"]
let parameters = [
  [
    "name": "file",
    "fileName": "<filename1>"
  ],
  [
    "name": "name",
    "value": 
  ],
  [
    "name": "layout",
    "value": 
  ],
  [
    "name": "curate",
    "value": 
  ]
]

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.taktoria.com/api/v1/meme-templates/upload")! 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()
```