Skip to main content
POST
/
socials_works
Create Social Work
curl --request POST \
  --url https://api.example.com/socials_works \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "address": "<string>",
  "phone": "<string>",
  "webpage": "<string>"
}
'
{
  "socialWork": {
    "id": 4,
    "name": "OSDE",
    "state": "Activa",
    "address": "Av. Leandro N. Alem 1067, CABA",
    "phone": "+54 11 4310-5555",
    "webpage": "https://www.osde.com.ar"
  }
}
Creates a new social work (health insurance provider) in the system.

Authentication

Requires a valid JWT token in the Authorization header and admin privileges.
Authorization: Bearer {token}
This endpoint requires admin role. Non-admin users will receive a 403 Forbidden error.

Request Body

name
string
required
Name of the social work (health insurance provider).Validation:
  • Cannot be empty
  • Must be unique in the system
Example: "OSDE"
address
string
required
Physical address of the social work office.Validation:
  • Cannot be empty
Example: "Av. Leandro N. Alem 1067, CABA"
phone
string
required
Contact phone number for the social work.Validation:
  • Cannot be empty
  • Must be between 10 and 20 characters
  • Can only contain numbers, spaces, hyphens, and plus signs
  • Pattern: /^[0-9\s\-\+]*$/
Examples:
  • "+54 11 4310-5555"
  • "0800-444-1200"
  • "11 5777 7777"
webpage
string
required
Website URL of the social work.Validation:
  • Cannot be empty
Example: "https://www.osde.com.ar"

Response

socialWork
object
The newly created social work object
{
  "socialWork": {
    "id": 4,
    "name": "OSDE",
    "state": "Activa",
    "address": "Av. Leandro N. Alem 1067, CABA",
    "phone": "+54 11 4310-5555",
    "webpage": "https://www.osde.com.ar"
  }
}

Code Examples

const token = 'your-admin-jwt-token';

const newSocialWork = {
  name: 'OSDE',
  address: 'Av. Leandro N. Alem 1067, CABA',
  phone: '+54 11 4310-5555',
  webpage: 'https://www.osde.com.ar'
};

const response = await fetch('https://api.clinicavitalis.com/socials_works', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${token}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify(newSocialWork)
});

const data = await response.json();
console.log(data.socialWork);

Validation Rules

Name Validation

  • Must be provided (not empty)
  • Must be unique across all social works in the system
  • Database will enforce uniqueness constraint

Phone Validation

  • Length: Between 10 and 20 characters
  • Format: Can only contain:
    • Numbers (0-9)
    • Spaces
    • Hyphens (-)
    • Plus sign (+)
  • Valid examples:
    • "+54 11 4310-5555"
    • "0800-444-1200"
    • "11 5777 7777"
    • "+54-11-4310-5555"
  • Invalid examples:
    • "123" (too short)
    • "(011) 4310-5555" (parentheses not allowed)
    • "tel:1234567890" (letters not allowed)

Address & Webpage

  • Both fields are required and cannot be empty
  • No format restrictions beyond being non-empty strings

State Management

  • New social works are automatically created with state "Activa" (Active)
  • The state field is set by default and cannot be specified during creation
  • To change the state to "Inactiva", use the Update Social Work endpoint

Notes

  • Only administrators can create social works
  • The social work name must be unique in the system
  • The state is automatically set to “Activa” upon creation
  • All fields except state are required in the request body
  • Validation errors will return a 400 status with detailed error messages

Build docs developers (and LLMs) love