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

# Login

POST https://qa.api.sellercenter.pe/sellercenter/security/v1/login
Content-Type: application/json

Inicia sesión con el usuario y la contraseña de Seller Center habilitados para APIs.

### Headers

| Header         | Valor               |
| -------------- | ------------------- |
| `apiKey`       | apiKey del ambiente |
| `Content-Type` | `application/json`  |

### Body

| Campo      | Tipo   | Requerido | Descripción                          |
| ---------- | ------ | --------- | ------------------------------------ |
| `username` | string | Sí        | Correo del usuario de Seller Center. |
| `password` | string | Sí        | Contraseña.                          |

### Respuesta `200`

| Campo                                | Descripción                                                                        |
| ------------------------------------ | ---------------------------------------------------------------------------------- |
| `data.accessToken`                   | **Token para las demás APIs.** Envíalo como `Authorization: Bearer <accessToken>`. |
| `data.expiresIn`                     | Vigencia en segundos (`86400` = 24 h).                                             |
| `data.idToken` / `data.refreshToken` | No se usan en esta integración.                                                    |

### Errores

| Código                            | Causa                                                      |
| --------------------------------- | ---------------------------------------------------------- |
| `401` con `FailedToResolveAPIKey` | Falta el header `apiKey`.                                  |
| `401`                             | Usuario o contraseña incorrectos, o son del otro ambiente. |

Reference: https://developers.sellercenter.pe/referencia-de-la-api/autenticacion/login

## Authentication

- `apiKey` header (required) — apiKey de tu ambiente (QA o PRD). La recibes por correo con tus credenciales.

## Servers

- `https://qa.api.sellercenter.pe/sellercenter` (QA, default)
- `https://prd.api.sellercenter.pe/sellercenter` (PRD)

## Request

### Body (application/json)

This endpoint expects an object.

- `username` (string, optional)
- `password` (string, optional)

## Response

### 200

Login exitoso

- `message` (string, optional)
- `status` (boolean, optional)
- `data` (SecurityV1LoginPostResponsesContentApplicationJsonSchemaData, optional)

## Errors

### 401 Unauthorized Error

Falta el header apiKey

- `fault` (SecurityV1LoginPostResponsesContentApplicationJsonSchemaFault, optional)

## Types

### SecurityV1LoginPostResponsesContentApplicationJsonSchemaData

- `accessToken` (string, optional)
- `idToken` (string, optional)
- `expiresIn` (double, optional)
- `refreshToken` (string, optional)

### SecurityV1LoginPostResponsesContentApplicationJsonSchemaFault

- `faultstring` (string, optional)
- `detail` (SecurityV1LoginPostResponsesContentApplicationJsonSchemaFaultDetail, optional)

### SecurityV1LoginPostResponsesContentApplicationJsonSchemaFaultDetail

- `errorcode` (string, optional)

## Examples

**Request**

```json
{
  "username": "usuario@tutienda.pe",
  "password": "tu-contraseña"
}
```

**Response**

```json
{
  "message": "request successfully",
  "status": true,
  "data": {
    "accessToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3VhcmlvQHNlbGxlci5jb20ifQ.firma-de-ejemplo",
    "idToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3VhcmlvQHNlbGxlci5jb20ifQ.firma-de-ejemplo",
    "expiresIn": 86400,
    "refreshToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3VhcmlvQHNlbGxlci5jb20ifQ.firma-de-ejemplo"
  }
}
```

**SDK Code**

```python Autenticacion_login_example
import requests

url = "https://qa.api.sellercenter.pe/sellercenter/security/v1/login"

payload = {
    "username": "usuario@tutienda.pe",
    "password": "tu-contraseña"
}
headers = {
    "apiKey": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Autenticacion_login_example
const url = 'https://qa.api.sellercenter.pe/sellercenter/security/v1/login';
const options = {
  method: 'POST',
  headers: {apiKey: '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"username":"usuario@tutienda.pe","password":"tu-contraseña"}'
};

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

```go Autenticacion_login_example
package main

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

func main() {

	url := "https://qa.api.sellercenter.pe/sellercenter/security/v1/login"

	payload := strings.NewReader("{\n  \"username\": \"usuario@tutienda.pe\",\n  \"password\": \"tu-contraseña\"\n}")

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

	req.Header.Add("apiKey", "<apiKey>")
	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 Autenticacion_login_example
require 'uri'
require 'net/http'

url = URI("https://qa.api.sellercenter.pe/sellercenter/security/v1/login")

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

request = Net::HTTP::Post.new(url)
request["apiKey"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"username\": \"usuario@tutienda.pe\",\n  \"password\": \"tu-contraseña\"\n}"

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

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

HttpResponse<String> response = Unirest.post("https://qa.api.sellercenter.pe/sellercenter/security/v1/login")
  .header("apiKey", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"username\": \"usuario@tutienda.pe\",\n  \"password\": \"tu-contraseña\"\n}")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://qa.api.sellercenter.pe/sellercenter/security/v1/login', [
  'body' => '{
  "username": "usuario@tutienda.pe",
  "password": "tu-contraseña"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'apiKey' => '<apiKey>',
  ],
]);

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

```csharp Autenticacion_login_example
using RestSharp;

var client = new RestClient("https://qa.api.sellercenter.pe/sellercenter/security/v1/login");
var request = new RestRequest(Method.POST);
request.AddHeader("apiKey", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"username\": \"usuario@tutienda.pe\",\n  \"password\": \"tu-contraseña\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Autenticacion_login_example
import Foundation

let headers = [
  "apiKey": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "username": "usuario@tutienda.pe",
  "password": "tu-contraseña"
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://qa.api.sellercenter.pe/sellercenter/security/v1/login")! 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()
```