Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/JanContrerasDev/gestor-contrasenas/llms.txt

Use this file to discover all available pages before exploring further.

Get Started in 5 Minutes

This guide will walk you through setting up the Password Manager API and making your first API request.
1

Clone and Install

First, clone the repository and install dependencies:
git clone https://github.com/JanContrerasDev/gestor-contrasenas.git
cd gestor-contrasenas
composer install
Make sure you have PHP 8.0.2 or higher and Composer installed on your system.
2

Configure Environment

Copy the example environment file and configure your database:
cp .env.example .env
php artisan key:generate
Edit .env and set your database credentials:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=password_manager
DB_USERNAME=your_username
DB_PASSWORD=your_password
3

Create Database and Run Migrations

Create the database and run migrations to set up tables:
mysql -u your_username -p -e "CREATE DATABASE password_manager;"
php artisan migrate
This creates the necessary passwords table with columns for password, sistema, usuario, and status.
4

Start the Development Server

Launch the Laravel development server:
php artisan serve
Your API is now running at http://localhost:8000
By default, Laravel serves on port 8000. You can specify a different port with --port=8080

Make Your First API Call

Now that your API is running, let’s create your first password entry.

Create a Password

Send a POST request to create a new password:
curl -X POST http://localhost:8000/api/createPassword \
  -H "Content-Type: application/json" \
  -d '{
    "password": "mySecurePassword123",
    "sistema": "GitHub",
    "usuario": "john.doe@example.com"
  }'
Expected Response:
{
  "message": "SE CREÓ UNA NUEVA CONTRASEÑA",
  "status": 200
}
All three fields (password, sistema, usuario) are required. Missing any field will return a 400 error with validation details.

Retrieve All Passwords

Fetch all active passwords in the system:
curl http://localhost:8000/api/listPassword
Expected Response:
[
  {
    "id": 1,
    "password": "mySecurePassword123",
    "sistema": "GitHub",
    "usuario": "john.doe@example.com",
    "status": 1
  }
]
The listPassword endpoint only returns passwords with status = 1 (active passwords).

Get a Specific Password

Retrieve a single password by ID:
curl http://localhost:8000/api/getPassword/1
Expected Response:
{
  "passwords": {
    "id": 1,
    "password": "mySecurePassword123",
    "sistema": "GitHub",
    "usuario": "john.doe@example.com",
    "status": 1
  },
  "status": 200
}

Update a Password

Modify an existing password entry:
curl -X POST http://localhost:8000/api/updatePassword/1 \
  -H "Content-Type: application/json" \
  -d '{
    "password": "newSecurePassword456",
    "sistema": "GitHub",
    "usuario": "john.doe@example.com"
  }'
Expected Response:
{
  "password": {
    "id": 1,
    "password": "newSecurePassword456",
    "sistema": "GitHub",
    "usuario": "john.doe@example.com",
    "status": 1
  },
  "message": "contraseña actualizada",
  "status": 200
}

Delete a Password

Soft delete a password (sets status to 0):
curl -X POST http://localhost:8000/api/deletePassword/1
Expected Response:
{
  "message": "contraseña borrada",
  "status": 200
}
Deletion is a soft delete operation. The password is marked as inactive (status = 0) but remains in the database.

API Endpoints Summary

List Passwords

GET /api/listPasswordReturns all active passwords

Get Password

GET /api/getPassword/{id}Retrieve a specific password by ID

Create Password

POST /api/createPasswordCreate a new password entry

Update Password

POST /api/updatePassword/{id}Update an existing password

Delete Password

POST /api/deletePassword/{id}Soft delete a password entry

Error Handling

The API returns standard HTTP status codes:
  • 200 - Success
  • 400 - Bad Request (validation errors)
  • 404 - Not Found (password doesn’t exist)
  • 500 - Internal Server Error

Common Errors

{
  "message": "Invalid data",
  "errors": {
    "password": ["The password field is required."],
    "sistema": ["The sistema field is required."],
    "usuario": ["The usuario field is required."]
  },
  "status": 400
}

Testing with Different Tools

# Create password
curl -X POST http://localhost:8000/api/createPassword \
  -H "Content-Type: application/json" \
  -d '{"password":"test123","sistema":"AWS","usuario":"admin"}'

Next Steps

API Reference

Detailed documentation for all endpoints

Authentication

Secure your API with Laravel Sanctum

Build docs developers (and LLMs) love