# Import a client logo — API reference

> Fetches a public HTTP(S) image for use as a Client logo.

Source: https://upfour.io/docs/api/clients/import-a-client-logo

[Developers](https://upfour.io/docs/api.md)/[Clients (agency mode)](https://upfour.io/docs/api/clients.md)

Fetches a public HTTP(S) image for use as a Client logo.

POST https://app.upfour.io/v1/clients/logo-import

scope client.write stable [Idempotency-Key supported](https://upfour.io/docs/api/idempotency.md) returns 200

## Body

`application/json` required 1 field

urlstring (required)

The http:// or https:// address of the image to fetch.

## Returns

A successful request returns `200` with application/json.

Response fields 1 top-level fields

| Field | Type | Description |
| --- | --- | --- |
| `data` | ClientLogoImportResponse | |
| ClientLogoImportResponse · 1 fields FieldTypeDescription `source` string The fetched image, base64 encoded; it is returned for the logo editor and not stored. | | |

## Errors

Only the errors this operation can return. Every error uses the [same envelope](https://upfour.io/docs/api/responses.md).

| Status | Code | Meaning |
| --- | --- | --- |
| 400 | [bad_request](https://upfour.io/docs/api/errors#code-bad_request) | The request is malformed or fails validation. |
| 400 | [logo_fetch_failed](https://upfour.io/docs/api/errors#code-logo_fetch_failed) | The image is not a public HTTP(S) image of at most 1 MiB or could not be fetched. **When:** Importing a client logo from a URL that cannot be reached or that does not return an acceptable image. **Fix:** Check the URL, or upload the logo file instead. `logo_fetch_failed`: the address is not a public HTTP(S) image of at most 1 MiB, or could not be fetched. |
| 404 | [not_found](https://upfour.io/docs/api/errors#code-not_found) | The requested resource does not exist or is outside the caller's scope. |
| 403 | [permission_denied](https://upfour.io/docs/api/errors#code-permission_denied) | The credentials do not permit this action. |

Every call can also return `unauthorized` (401), `rate_limit_exceeded` (429) or `internal_error` (500 / 502). See [Responses and errors](https://upfour.io/docs/api/responses.md).

[PreviousUpdate a client](https://upfour.io/docs/api/clients/update-a-client.md) [NextGet client portal settings](https://upfour.io/docs/api/clients/get-client-portal-settings.md)

## Request

### cURL

```bash
curl -s -X POST "https://app.upfour.io/v1/clients/logo-import" \
  -H "Authorization: Bearer $UP4_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com"
  }'
```

### JavaScript

```javascript
const res = await fetch("https://app.upfour.io/v1/clients/logo-import", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UP4_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://example.com",
  }),
});
console.log(res.status, await res.json());
```

### Python

```python
import os
import requests

res = requests.post(
    "https://app.upfour.io/v1/clients/logo-import",
    headers={"Authorization": f"Bearer {os.environ['UP4_API_KEY']}"},
    json={
        "url": "https://example.com",
    },
)
print(res.status_code, res.json())
```

### Go

```go
package main

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

func main() {
	payload := strings.NewReader(`{
  "url": "https://example.com"
}`)
	req, _ := http.NewRequest("POST", "https://app.upfour.io/v1/clients/logo-import", payload)
	req.Header.Set("Authorization", "Bearer "+os.Getenv("UP4_API_KEY"))
	req.Header.Set("Content-Type", "application/json")
	res, err := http.DefaultClient.Do(req)
	if err != nil {
		panic(err)
	}
	defer res.Body.Close()
	out, _ := io.ReadAll(res.Body)
	fmt.Println(res.StatusCode, string(out))
}
```

### PHP

```php
<?php
$payload = <<<'JSON'
{
  "url": "https://example.com"
}
JSON;

$ch = curl_init("https://app.upfour.io/v1/clients/logo-import");
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => "POST",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        "Authorization: Bearer " . getenv("UP4_API_KEY"),
        "Content-Type: application/json",
    ],
    CURLOPT_POSTFIELDS => $payload,
]);
$response = curl_exec($ch);
echo curl_getinfo($ch, CURLINFO_RESPONSE_CODE), " ", $response, "\n";
curl_close($ch);
```

## Response

### 200

```json
{
  "data": {
    "source": "example"
  }
}
```

### 400

```json
{
  "error": {
    "code": "bad_request",
    "message": "The request is malformed or fails validation.",
    "request_id": "req_…"
  }
}
```

### 403

```json
{
  "error": {
    "code": "permission_denied",
    "message": "The credentials do not permit this action.",
    "request_id": "req_…"
  }
}
```

### 404

```json
{
  "error": {
    "code": "not_found",
    "message": "The requested resource does not exist or is outside the caller's scope.",
    "request_id": "req_…"
  }
}
```
