> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# テンプレートを取得

GET https://api.elevenlabs.io/v1/flows/templates/{template_id}

1つのフローテンプレートを、実行可能な各バージョンの入力と出力とともに取得します。このAPIで実行可能な公開バージョンがない場合、`versions`は空です。`GET /v1/flows/templates`には一覧表示されない、リンクで共有されたテンプレートや別のワークスペースからExploreに公開されたテンプレートを含め、開くことができる任意のテンプレートで利用できます。

Reference: https://elevenlabs.io/docs/api-reference/flows/templates/get

## Servers

- `https://api.elevenlabs.io` (Production, default)
- `https://api.us.elevenlabs.io` (Production US)
- `https://api.eu.residency.elevenlabs.io` (Production EU)
- `https://api.in.residency.elevenlabs.io` (Production India)
- `https://api.sg.residency.elevenlabs.io` (Production Singapore)

## Request

### Path parameters

- `template_id` (string, required) — ElevenLabsアプリまたは`GET /v1/flows/templates`に表示されるテンプレートのID。

### Query parameters

- `versions_per_template` (integer, optional, default: 10) — 各テンプレートの公開済みバージョンを、新しい順にいくつ返すかを指定します。テンプレートにさらにバージョンがある場合は、`has_more_versions`で確認できます。

## Response

### 200

成功レスポンス。

- `id` (string, required) — `POST /v1/flows/templates/{template_id}/runs`で`template_id`として渡します。
- `name` (string, required) — テンプレートの名前。
- `versions` (list of TemplateVersion, required) — 呼び出し元が実行できる公開済みバージョン。新しい順に並びます。グラフでAPIから利用できないモデルを使用するバージョンや、保存済みスナップショットが失われたバージョンは除外されます。いずれの場合も、ElevenLabsアプリで実行可能なバージョンがテンプレートに残っていても、リストが空になることがあります。
- `has_more_versions` (boolean, required) — このテンプレートに、ここで返される`versions_per_template`以外の公開済みバージョンがあるかどうか。さらに表示するには、より大きい`versions_per_template`を指定して`GET /v1/flows/templates/{template_id}`を取得してください。
- `description` (string, optional, nullable) — テンプレートの説明（存在する場合）。

## Errors

### 422 Unprocessable Entity Error

検証エラー

- `detail` (list of ValidationError, optional)

## Types

### TemplateVersion

テンプレートの公開済みスナップショットと、それが実行されるポート。

- `version_id` (string, required) — 実行をこのスナップショットに固定するには、`POST /v1/flows/templates/{template_id}/runs`で`version_id`として渡します。
- `published_at_unix` (integer, required) — このバージョンが公開された日時（秒単位のUnixタイムスタンプ）。
- `is_latest` (boolean, required) — `version_id`が省略されるか`latest`に設定された場合に、実行で使用されるバージョンかどうか。
- `inputs` (list of TemplatePort, required) — このバージョンが受け付ける入力。キャンバスの順序で並びます。実行時にはすべての入力が必要です。
- `outputs` (list of TemplatePort, required) — このバージョンが生成する出力。キャンバス上の順序で並びます。

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### TemplatePort

公開済みテンプレートバージョンの1つの入力ポートまたは出力ポートです。

- `id` (string, required) — ポートID。入力IDは`POST /v1/flows/templates/{template_id}/runs`の`inputs`マップのキーであり、出力IDは実行レスポンスの`outputs`マップのキーです。
- `content_schema` (ContentSchema, required) — このポートが受け付ける、または生成する内容を`ContentSchema`として示します。`title`はポートの表示名、`description`はテンプレート作成者が記述したヘルプテキストです。入力では、`type`によって受け付ける値が決まります。`string`は文字列または`generation`参照、`voice`は`voice`参照、`image`／`video`／`audio`は`asset`、`generation`、または`inline_base64`参照を受け付けます。`number`、`integer`、`boolean`は該当する型のJSON値を受け付けます。`array`入力は、要素ごとに`items`で許容される値を1つ含むJSON配列を受け付けます。`object`入力は、まだこのAPIではバインドできません。`string`スキーマには、受け付ける値のみを指定した`enum`を含めることができます。出力では、`type`によって、実行レスポンス内でポートIDの下に格納される`Template<Kind>Output`の形状が決まります。

### ValidationErrorLocItems

### ContentSchema

- `type`: `array` (ArraySchema)
  - `items` (ContentSchema, required)
  - `description` (string, optional, nullable)
  - `title` (string, optional, nullable)
- `type`: `audio` (AudioSchema)
  - `description` (string, optional, nullable)
  - `title` (string, optional, nullable)
- `type`: `boolean` (BooleanSchema)
  - `description` (string, optional, nullable)
  - `title` (string, optional, nullable)
- `type`: `image` (ImageSchema)
  - `description` (string, optional, nullable)
  - `title` (string, optional, nullable)
- `type`: `integer` (IntegerSchema)
  - `description` (string, optional, nullable)
  - `title` (string, optional, nullable)
- `type`: `number` (NumberSchema)
  - `description` (string, optional, nullable)
  - `enum` (list of double, optional, nullable)
  - `title` (string, optional, nullable)
- `type`: `object` (ObjectSchema)
  - `description` (string, optional, nullable)
  - `properties` (map from string to ContentSchema, optional)
  - `required` (list of string, optional)
  - `title` (string, optional, nullable)
- `type`: `string` (StringSchema)
  - `description` (string, optional, nullable)
  - `enum` (list of string, optional, nullable)
  - `title` (string, optional, nullable)
- `type`: `video` (VideoSchema)
  - `description` (string, optional, nullable)
  - `title` (string, optional, nullable)
- `type`: `voice` (VoiceSchema)
  - `description` (string, optional, nullable)
  - `title` (string, optional, nullable)

## Examples

**Response**

```json
{
  "id": "tmpl_abc123",
  "name": "Product shot",
  "versions": [
    {
      "version_id": "ver_01hxyz",
      "published_at_unix": 1,
      "is_latest": true,
      "inputs": [
        {
          "id": "prompt",
          "content_schema": {
            "type": "string",
            "description": "string",
            "enum": [
              "string"
            ],
            "title": "string"
          }
        }
      ],
      "outputs": [
        {
          "id": "prompt",
          "content_schema": {
            "type": "string",
            "description": "string",
            "enum": [
              "string"
            ],
            "title": "string"
          }
        }
      ]
    }
  ],
  "has_more_versions": true,
  "description": "string"
}
```

**SDK Code**

```python
import requests

url = "https://api.elevenlabs.io/v1/flows/templates/template_id"

response = requests.get(url)

print(response.json())
```

```javascript
const url = 'https://api.elevenlabs.io/v1/flows/templates/template_id';
const options = {method: 'GET'};

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"
	"net/http"
	"io"
)

func main() {

	url := "https://api.elevenlabs.io/v1/flows/templates/template_id"

	req, _ := http.NewRequest("GET", url, nil)

	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.elevenlabs.io/v1/flows/templates/template_id")

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

request = Net::HTTP::Get.new(url)

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.get("https://api.elevenlabs.io/v1/flows/templates/template_id")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.elevenlabs.io/v1/flows/templates/template_id');

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

```csharp
using RestSharp;

var client = new RestClient("https://api.elevenlabs.io/v1/flows/templates/template_id");
var request = new RestRequest(Method.GET);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let request = NSMutableURLRequest(url: NSURL(string: "https://api.elevenlabs.io/v1/flows/templates/template_id")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"

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()
```