> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hoox.video/llms.txt
> Use this file to discover all available pages before exploring further.

# Edit Avatar Look

> Create a new look for an existing avatar by editing from an existing look with a prompt

## Overview

This endpoint creates a new look for an existing avatar by editing a source look using AI. The source look is not modified - a new look is created based on it.

## Authentication

<Info>
  This endpoint requires API key authentication. Include your API key in the `Authorization` header.
</Info>

## Request Body

<ParamField body="avatar_id" type="string" required>
  Unique identifier of the avatar to edit.
</ParamField>

<ParamField body="look_id" type="string" required>
  Unique identifier of the source look to use as base for editing.
</ParamField>

<ParamField body="prompt" type="string" required>
  Text prompt describing how to edit the look.
</ParamField>

<ParamField body="format" type="string" default="vertical">
  Image format: `vertical` (9:16) or `horizontal` (16:9). Defaults to `vertical`.
</ParamField>

<ParamField body="style" type="string">
  Avatar style to apply: `selfie`, `podcast`, `car`, `iphone`, `conference`, or `raw`.
</ParamField>

<ParamField body="imageUrls" type="array">
  Additional image URLs to use for editing. The source look's image is automatically added first if available.
</ParamField>

<ParamField body="resolution" type="string" default="2K">
  Output image resolution: `2K` or `4K`. Optional, defaults to `2K`. Note that `4K` generation costs more credits.
</ParamField>

<ParamField body="webhook_url" type="string">
  URL to receive webhook notifications when generation completes.
</ParamField>

## Response

<ResponseField name="avatar_id" type="string">
  Unique identifier of the avatar.
</ResponseField>

<ResponseField name="look_id" type="string">
  Unique identifier of the newly created look. This look starts in "pending" status.
</ResponseField>

## Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://app.hoox.video/api/public/v1/avatar/edit" \
    -H "Authorization: Bearer your_api_key" \
    -H "Content-Type: application/json" \
    -d '{
      "avatar_id": "avtr_123",
      "look_id": "look_src",
      "prompt": "Add my product in his hand",
      "format": "vertical",
      "style": "iphone",
      "imageUrls": ["https://cdn.example.com/extra.jpg"],
      "resolution": "2K",
      "webhook_url": "https://example.com/webhooks/avatar-edit"
    }'
  ```

  ```python Python theme={null}
  import requests

  url = "https://app.hoox.video/api/public/v1/avatar/edit"
  headers = {
      "Authorization": "Bearer your_api_key",
      "Content-Type": "application/json"
  }

  data = {
      "avatar_id": "avtr_123",
      "look_id": "look_src",
      "prompt": "Sharper portrait, cinematic lighting",
      "format": "vertical",
      "style": "iphone",
      "imageUrls": ["https://cdn.example.com/extra.jpg"],
      "resolution": "2K",
      "webhook_url": "https://example.com/webhooks/avatar-edit"
  }

  response = requests.post(url, headers=headers, json=data)
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://app.hoox.video/api/public/v1/avatar/edit', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer your_api_key',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      avatar_id: "avtr_123",
      look_id: "look_src",
      prompt: "Sharper portrait, cinematic lighting",
      format: "vertical",
      style: "iphone",
      imageUrls: ["https://cdn.example.com/extra.jpg"],
      resolution: "2K",
      webhook_url: "https://example.com/webhooks/avatar-edit"
    })
  });

  const data = await response.json();
  console.log(data);
  ```
</RequestExample>

<ResponseExample>
  ```json Success Response theme={null}
  {
    "avatar_id": "avtr_123",
    "look_id": "look_new"
  }
  ```

  ```json Error 400 - Validation Failed theme={null}
  {
    "error": "Validation failed",
    "details": [
      {
        "code": "MISSING_AVATAR_ID",
        "message": "avatar_id is required",
        "field": "avatar_id"
      }
    ]
  }
  ```

  ```json Error 404 - Avatar Not Found theme={null}
  {
    "error": "Avatar not found"
  }
  ```

  ```json Error 402 - Insufficient Credits theme={null}
  {
    "error": "Insufficient credits",
    "required": 2,
    "available": 1
  }
  ```
</ResponseExample>

## Credit Costs

* **Base cost (2K)**: 2 credits
* **Base cost (4K)**: 4 credits

## Next Steps

1. **Check Status**: Use `/avatar/status` endpoint to monitor the generation progress
2. **List Looks**: Use `/avatar/list` to see all available looks for your avatar

## Error Codes

* `MISSING_AVATAR_ID`: avatar\_id parameter is required
* `MISSING_LOOK_ID`: look\_id parameter is required
* `INVALID_WEBHOOK_URL`: webhook\_url must be a valid URL
* `MISSING_PROMPT`: prompt parameter is required
* `NO_IMAGE_AVAILABLE`: No image available (source look has no thumbnail and images array is empty)
* `INSUFFICIENT_CREDITS`: Not enough credits to edit the avatar
* `SPACE_NOT_FOUND`: Space doesn't exist
* `AVATAR_NOT_FOUND`: Avatar with specified ID doesn't exist
* `LOOK_NOT_FOUND`: Look with specified ID doesn't exist
* `FAILED_TO_PERSIST`: Error saving new look to database
* `GENERATION_FAILED`: Look generation failed (async error sent via webhook)
