# /login/raw

This endpoint is the simplest way to login into your Siga 3 account. When logged it will return the Siga 3 server it's using, the Siga session cookie, your client session cookie, and a logged variable equal to true meaning you successfully logged into your Siga 3 account.

## Load the Siga

This method requires u to have a loaded Siga session:

[/load](/mysiga/reference/load.md#load-siga-session)

If you need or want to log in using captcha, u need to load a Siga session with captcha data:

[/load](/mysiga/reference/load.md#load-siga-session-with-captcha)

With the Siga session loaded, you should have the following values:

* `challenge` The challenge hash.
* `captcha` Will be `null` if loaded without captcha
  * `id` Captcha identifier
  * `numbers` An array of the captcha values
  * `tip` A tip on what to do with the captcha values
* `server` Base Siga URL given by Siga's load balancer
* `siga` Siga session id
* `client` MySiga session id

## Encrypting the password

This login method doesn't accept the user password, u have to encrypt the password using the given challenge hash and use the generated hash to log in. This is the way to do it:

```
MD5(user : MD5(password) : challenge)
```

{% tabs %}
{% tab title="PHP" %}

```php
$cpf = '12345678901';
$password = '12345678';
$challenge = '1816466375646a6b2518ae6';

$response = md5($cpf.':'.md5($password).':'.$challenge);
// response will be like: 2717466375646a6b8518ae7
```

{% endtab %}
{% endtabs %}

## Raw Authentication

<mark style="color:green;">`POST`</mark> `https://mysiga.laravieira.me/login/raw`

This will get the CPF and the response and login into Siga server.

#### Cookies

| Name                                        | Type   | Description    |
| ------------------------------------------- | ------ | -------------- |
| PHPSESSID<mark style="color:red;">\*</mark> | string | The session id |

#### Request Body

| Name                                       | Type   | Description                |
| ------------------------------------------ | ------ | -------------------------- |
| cpf<mark style="color:red;">\*</mark>      | string | The user CPF, only numbers |
| response<mark style="color:red;">\*</mark> | string | The encrypted password     |
| captcha                                    | int    | The captcha resolution     |

{% tabs %}
{% tab title="200 Successful logged" %}

```json
{
    "server": "*",
    "siga": "*",
    "client": "*",
    "logged": true
}
```

`server` Base URL to the Siga 3 server selected by Siga's load balancer.

`siga` Siga session id.

`client` Session id of MySiga API.

`logged` If the user was logged in, is always true and only exists on the 200 response code.
{% endtab %}

{% tab title="400: Bad Request No valid CPF" %}
The value to the CPF field is missing or not a valid CPF.

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "code": 400,
    "message": "No valid CPF.",
    "uri": "/login",
    "server": null,
    "siga": null,
    "client": "*",
    "docs": "https://docs.laravieira.me/mysiga",
    "date": "Sun, 21 May 2023 13:41:34 -0300"
}
</code></pre>

{% endtab %}

{% tab title="400: Bad Request No valid response" %}
The given value to the response field is not valid or is missing.

```json
{
    "code": 400,
    "message": "No valid response.",
    "uri": "/login",
    "server": null,
    "siga": null,
    "client": "*",
    "docs": "https://docs.laravieira.me/mysiga",
    "date": "Sun, 21 May 2023 13:45:50 -0300"
}
```

{% endtab %}

{% tab title="400: Bad Request No valid captcha" %}
The given captcha resolution is not valid.

```json
{
    "code": 400,
    "message": "No valid captcha.",
    "uri": "/login",
    "server": null,
    "siga": null,
    "client": "*",
    "docs": "https://docs.laravieira.me/mysiga",
    "date": "Sun, 21 May 2023 13:41:34 -0300"
}
```

{% endtab %}

{% tab title="401: Unauthorized This CPF isn't registered in Siga servers" %}

```json
{
    "code": 401,
    "message": "This CPF isn't registered in Siga servers.",
    "uri": "/login",
    "server": null,
    "siga": null,
    "client": "*",
    "docs": "https://docs.laravieira.me/mysiga",
    "date": "Sun, 21 May 2023 13:41:34 -0300"
}
```

{% endtab %}

{% tab title="401: Unauthorized Wrong Password" %}
The given response field doesn't match the hash for the given challenge, or u encrypted it wrongly or the password is wrong.

```json
{
    "code": 401,
    "message": "Wrong Password.",
    "uri": "/login",
    "server": null,
    "siga": null,
    "client": "*",
    "docs": "https://docs.laravieira.me/mysiga",
    "date": "Sun, 21 May 2023 13:41:34 -0300"
}
```

{% endtab %}

{% tab title="401: Unauthorized Captcha wrong" %}
The captcha resolution is wrong. U need to reload the Siga with [/load](/mysiga/reference/load.md#load-siga-session-with-captcha) to get a new captcha and try resolving it again.

```json
{
    "code": 401,
    "message": "Captcha wrong.",
    "uri": "/login",
    "server": null,
    "siga": null,
    "client": "*",
    "docs": "https://docs.laravieira.me/mysiga",
    "date": "Sun, 21 May 2023 13:41:34 -0300"
}
```

{% endtab %}

{% tab title="424: Failed Dependency You need to load a siga session before trying login" %}
With this raw login method, u need to load Siga using [/load](/mysiga/reference/load.md#load-siga-session) to only then try to log in.

```json
{
    "code": 424,
    "message": "You need to load a siga session before trying login.",
    "uri": "/login",
    "server": null,
    "siga": null,
    "client": "*",
    "docs": "https://docs.laravieira.me/mysiga",
    "date": "Sun, 21 May 2023 13:41:34 -0300"
}
```

{% endtab %}

{% tab title="424: Failed Dependency You need to load a siga captcha before trying login with it" %}
With this raw login method, u need to load Siga using [/load](/mysiga/reference/load.md#load-siga-session-with-captcha) to only then try to log in with captcha.

```json
{
    "code": 424,
    "message": "You need to load a siga captcha before trying login with it.",
    "uri": "/login",
    "server": null,
    "siga": null,
    "client": "*",
    "docs": "https://docs.laravieira.me/mysiga",
    "date": "Sun, 21 May 2023 13:41:34 -0300"
}
```

{% endtab %}

{% tab title="401: Unauthorized Captcha required" %}
U need to load the Siga again, but using [/load](/mysiga/reference/load.md#load-siga-session-with-captcha) to get captcha data and send the login request with the captcha resolution.

```json
{
    "code": 401,
    "message": "Captcha required.",
    "uri": "/login",
    "server": null,
    "siga": null,
    "client": "*",
    "docs": "https://docs.laravieira.me/mysiga",
    "date": "Sun, 21 May 2023 13:41:34 -0300"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
If your response is an exception not listed here, u might wanna check[General Exceptions](/mysiga/reference/general-exceptions.md).
{% 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://docs.laravieira.me/mysiga/reference/login/login-raw.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.
