# Two-Factor Authentication (2FA)

Several operations are restricted and require user-inputted Two-Factor Authentication. The Ping Proxies API provides a standardized framework to receive and respond to 2FA requests.

Two-Factor Authentication may be required for any operation depending on customer settings and Ping Proxies' current security policies. As such, applications should implement an adaptive and repeatable method to respond to 2FA requests.

**Two-Factor Authentication Flowchart**

The diagram below illustrates the intended Two-Factor Authentication application flow. All 2FA requests are issued consistent to this standardized framework below.

<figure><img src="/files/Kv44KhqHhrPntjiogoLS" alt=""><figcaption></figcaption></figure>

**Two-Factor Authentication Request Flow**

1. Request Sent

```
POST /v1.0/private/user/customer/login

JSON-Encoded Body

{
    "customer_email_address": "example@pingproxies.com",
    "customer_password":  "Example123",
}
```

2. API Responds with 499, Two-Factor Authentication Required

<pre><code>{
    "error": "Two Factor Authentication Required",
    "message": "Two factor authentication key required.",
    "two_factor_authentication_public_key": "KcSOSAiKqAs7xjz318XCOkiiEUBqW1Me",
    "two_factor_authentication_service": "email",
    "two_factor_authentication_target": "e**@pingproxies.com"
<strong>}, 499
</strong></code></pre>

3. Customer inputs the two\_factor\_authentication\_private\_key to the application and the application retries the original request with the two\_factor\_authentication\_private\_key and two\_factor\_authentication\_public\_key appended to the JSON-encoded request body.

```
POST /v1.0/private/user/customer/login

JSON-Encoded Body

{
    "customer_email_address": "example@pingproxies.com",
    "customer_password":  "Example123",
    "two_factor_authentication_public_key": "KcSOSAiKqAs7xjz318XCOkiiEUBqW1Me",
    "two_factor_authentication_private_key": "917421"
}
```

4. Assuming the two\_factor\_authentication\_private\_key is correct and corresponds with the two\_factor\_authentication\_public\_key, the request is successful and is processed as normal with the API.

```
{
    "data": {
        "access_token": "eyJhbGciOiJIVzaCI6ZmFsc2UsImlhdCI6MTY5NTAzMjk1NywianRpIjoiZDk3OWJiNDMtYzA2Mi00M2MzLTg0YTYtYWMxMzc3M2MyNjFiIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6eyJjdXN0b21lcl9pZCI6NiwiY3VzdG9tZXJfZmlyc3RfbmFtZSI6IkpvaG56IiwiY3VzdG9tZXJfbGFzdF9uYW1lIjoiUHJveGllcyIsImN1c3RvbWVyX2VtYWlsX2FkZHJlc3MiOiJ4eHhAcGluZ3Byb3hpZXMuY29tIiwiY3VzdG9tZXJfc2Vzc2lvbl9rZXkiOiJGM2lCMjZXT0VkVnRNcVpMczNoWEN4YjZlMGROSnIwS0V0Qm5SWllJV0JndWNMZ2xWVWw3RE9QU1JRcVNSZDRJODZ5bUpjODNCdnRxTHc4QW5PZzVXRUxQeEFhc09UaTRlV1dIIiwiY3VzdG9tZXJfaXNfYWRtaW4iOnRydWUsImN1c3RvbWVyX2FkbWluX3R5cGUiOiJBTEwiLCJzZXNzaW9uX2NyZWF0aW9uX3RpbWUiOiJNb24sIDE4IFNlcCAyMDIzIDEwOjI5OjE3IEdNVCIsInNlc3Npb25faXBfYWRkcmVzcyI6Ijc4LjMzLjI0LjE3OCJ9LCJuYmYiOjE2OTUwMzI5NTcsImV4cCI6MTcyNjU2ODk1N30.n_TI1IcW-XEEafz_1eNUevavthQXrRclRjMhM-HAvys"
        },
    "message": "Login successful."
}, 200
```

{% hint style="warning" %}
Two-Factor Authentication tokens are valid for 10 minutes. After that period, they will no longer work and the API will respond to requests with 499, Two-Factor Authentication Required and issue a new token.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://internal.developer.documentation.private.user.pingproxies.com/basic-concepts/two-factor-authentication-2fa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
