# Obtener Version - [version]

## 🧾 **Descripción**

*Obtiene la versión actual de una aplicación móvil específica.*  
*El servicio valida si el identificador de la app existe y, de ser así, devuelve la versión correspondiente.*

**Este endpoint se usa para:**

- Mostrar la versión actual al usuario
- Verificar actualizaciones desde la app móvil
- Controlar múltiples aplicaciones dentro del mismo backend

---

# 🚀 **Endpoint**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-post-%2Fversion"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs">  
</div></div></div><div class="overflow-y-auto p-4" dir="ltr"><span style="color: rgb(224, 62, 45);">**`POST /version`**</span></div></div>> La ruta final dependerá del archivo de rutas (**<span style="color: rgb(224, 62, 45);">`routes/api.php`</span>**).

---

# 🔐 **Seguridad**

- Sin autenticación explícita
- Normalmente accesible para todas las apps móviles

---

# 📥 **Request Body**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk--3"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div><table border="1" id="bkmrk-%7B-%22app%22%3A-%22string%22-%7D" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"app"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

### Campos

<div class="_tableContainer_1rjym_1" id="bkmrk-campo-tipo-requerido"><div class="group _tableWrapper_1rjym_13 flex w-fit flex-col-reverse" tabindex="-1"><table class="w-fit min-w-(--thread-content-width)" data-end="1046" data-start="860"><thead data-end="904" data-start="860"><tr data-end="904" data-start="860"><th data-col-size="sm" data-end="868" data-start="860">Campo</th><th data-col-size="sm" data-end="877" data-start="868">Tipo</th><th data-col-size="sm" data-end="889" data-start="877">Requerido</th><th data-col-size="md" data-end="904" data-start="889">Descripción</th></tr></thead><tbody data-end="1046" data-start="950"><tr data-end="1046" data-start="950"><td data-col-size="sm" data-end="958" data-start="950">app</td><td data-col-size="sm" data-end="967" data-start="958">string</td><td data-col-size="sm" data-end="979" data-start="967">Sí</td><td data-col-size="md" data-end="1046" data-start="979">Identificador de la aplicación cuya versión se desea consultar.</td></tr></tbody></table>

</div></div>---

# 📤 **Responses**

## ✔️ 200 – App encontrada (Versión obtenida)

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk--5"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div><table border="1" id="bkmrk-%7B-%22valor%22%3A-true%2C-%22ms" style="border-collapse: collapse; width: 100%; height: 33.8px;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr style="height: 33.8px;"><td style="height: 33.8px;">`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Versión del app MiApp: 1.0.5"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"version"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"1.0.5"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

*El nombre mostrado proviene de:* <span style="color: rgb(224, 62, 45);">**`<span class="hljs-variable">$name_app</span> = <span class="hljs-variable language_">$this</span>->apps[<span class="hljs-variable">$app</span>];`**</span>

*La versión proviene de:* <span style="color: rgb(224, 62, 45);">**`<span class="hljs-variable">$versiones</span> = <span class="hljs-variable language_">$this</span>-><span class="hljs-title function_ invoke__">data</span>();<span class="hljs-variable">$version</span> = <span class="hljs-variable">$versiones</span>[<span class="hljs-variable">$app</span>];`**</span>

---

## ❌ 404 / 200 – App no existente

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-false%2C-%22m"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">false</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"No existe esa app"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>> Nota: El método devuelve **200 OK** incluso cuando la app no existe.  
> (Esto es comportamiento actual del código.)

---

# 🧩 **Lógica Interna**

1. Recibe el parámetro <span style="color: rgb(224, 62, 45);">**`app`**</span>.
2. Obtiene todas las versiones desde <span style="color: rgb(224, 62, 45);">**`$this->data()`**</span>  
    *(método interno que no está mostrado pero retorna un array asociativo)*.
3. Valida si la clave <span style="color: rgb(224, 62, 45);">**`app`**</span> existe en el array versiones:
    
    
    - **No existe** → error
    - **Existe** → procede
4. Obtiene el nombre de la app desde: <span style="color: rgb(224, 62, 45);">**`<span class="hljs-variable">$this</span>->apps[<span class="hljs-variable">$app</span>]`**</span>
5. Obtiene la versión asociada: `<span class="hljs-variable"><strong><span style="color: rgb(224, 62, 45);">$versiones</span></strong></span><strong><span style="color: rgb(224, 62, 45);">[<span class="hljs-variable">$app</span>]</span></strong>`
6. Devuelve la versión actual en el message.

---

# 📚 **Schema**

### Request

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk--9"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div><table border="1" id="bkmrk-%7B-%22app%22%3A-%22string%22-%7D-1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"app"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

### Response

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk--10"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div><table border="1" id="bkmrk-%7B-%22valor%22%3A-%22boolean%22" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"boolean"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"version"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"string (opcional)"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

---

# 🧪 **Ejemplo de Uso (curl)**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk--12"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div><table border="1" id="bkmrk-curl--x-post-https%3A%2F" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`curl -X POST https://midominio.com/api/version \-H <span class="hljs-string">"Content-Type: application/json"</span> \-d <span class="hljs-string">'{"app":"shalom_app"}'</span>`</td></tr></tbody></table>

**Respuesta esperada:**

<div class="contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary" id="bkmrk-%7B-%22valor%22%3A-true%2C-%22ms-1"><div class="sticky top-9"><div class="absolute end-0 bottom-0 flex h-9 items-center pe-2"><div class="bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs"><table border="1" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 99.881%;"></col></colgroup><tbody><tr><td>`<span class="hljs-punctuation">{</span>  <span class="hljs-attr">"valor"</span><span class="hljs-punctuation">:</span> <span class="hljs-literal"><span class="hljs-keyword">true</span></span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"msn"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"Versión del app Shalom App: 3.1.4"</span><span class="hljs-punctuation">,</span>  <span class="hljs-attr">"version"</span><span class="hljs-punctuation">:</span> <span class="hljs-string">"3.1.4"</span><span class="hljs-punctuation">}</span>`</td></tr></tbody></table>

</div></div></div><div class="overflow-y-auto p-4" dir="ltr"></div></div>