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

# Index an account by website or social URL

POST https://api.spyglass.so/v2/account/index
Content-Type: application/json

Look up a brand by website URL, or start indexing it if we do not
have it yet. Pass a single `websiteUrl`. Instagram and TikTok
profile URLs are accepted and resolved as creators.

This endpoint does not consume credits. An existing brand returns
`status: "already_exists"`. A new brand is created and sync is
queued, returning `status: "indexing"` and the new `brandId`.

Limited to 50 requests per minute per user.
This call is free.

Reference: https://docs.spyglass.so/api-reference/spyglass-api/social-media-account/index-account

## Authentication

- `Authorization` header (bearer token, required) — An API key from Settings → API, prefixed sg_live_.

## Request

### Body (application/json)

This endpoint expects an object.

- `websiteUrl` (string, required)

## Response

### 200

The brand id and whether indexing was started.

- `brandId` (string, required)
- `status` (enum, required)
  - Allowed values: `already_exists`, `indexing`

## Errors

### 400 Bad Request Error

The request body or query string failed validation. `details` lists the offending fields.

- `error` (ErrorError, required)

### 401 Unauthorized Error

The API key is missing, malformed, unknown, or revoked.

- `error` (ErrorError, required)

### 403 Forbidden Error

The team's subscription is inactive, or your membership of it has ended.

- `error` (ErrorError, required)

### 405 Method Not Allowed Error

The HTTP method is not supported on this path. The Allow header lists what is. HEAD is refused on metered GET endpoints because it would be billed without returning data.

- `error` (ErrorError, required)

### 413 Content Too Large Error

The request body exceeds the 100 KB limit.

- `error` (ErrorError, required)

### 429 Too Many Requests Error

Too many requests for this user on this endpoint. Carries a Retry-After header. The per-minute limit is stated on the operation.

- `error` (ErrorError, required)

### 500 Internal Server Error

Something went wrong on our side.

- `error` (ErrorError, required)

## Types

### ErrorError

- `code` (enum, required)
  - Allowed values: `invalid_request`, `invalid_api_key`, `payload_too_large`, `out_of_credits`, `membership_ended`, `subscription_inactive`, `brand_not_found`, `not_found`, `method_not_allowed`, `rate_limited`, `internal_error`
- `message` (string, required)
- `details` (list of ErrorErrorDetailsItems, optional)

### ErrorErrorDetailsItems

- `path` (string, required)
- `message` (string, required)

## Examples

**Request**

```json
{
  "websiteUrl": "https://www.nike.com"
}
```

**Response**

```json
{
  "brandId": "string",
  "status": "already_exists"
}
```

**SDK Code**

```python account_index_example
import requests

url = "https://api.spyglass.so/v2/account/index"

payload = { "websiteUrl": "https://www.nike.com" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript account_index_example
const url = 'https://api.spyglass.so/v2/account/index';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
  body: '{"websiteUrl":"https://www.nike.com"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go account_index_example
package main

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

func main() {

	url := "https://api.spyglass.so/v2/account/index"

	payload := strings.NewReader("{\n  \"websiteUrl\": \"https://www.nike.com\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby account_index_example
require 'uri'
require 'net/http'

url = URI("https://api.spyglass.so/v2/account/index")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"websiteUrl\": \"https://www.nike.com\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://api.spyglass.so/v2/account/index")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"websiteUrl\": \"https://www.nike.com\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.spyglass.so/v2/account/index', [
  'body' => '{
  "websiteUrl": "https://www.nike.com"
}',
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/json',
  ],
]);

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

```csharp account_index_example
using RestSharp;

var client = new RestClient("https://api.spyglass.so/v2/account/index");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"websiteUrl\": \"https://www.nike.com\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift account_index_example
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
]
let parameters = ["websiteUrl": "https://www.nike.com"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.spyglass.so/v2/account/index")! 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()
```