Skip to content

Parts API

This document describes the endpoints for managing parts in the system.

Get Part

Retrieve details for a specific part.

Endpoint: /_a/part/{part_id}

Method: GET

Headers:

  • Authorization: Bearer <access_token>

Success Response:

  • Code: 200 OK
{
    "id": "123",
    "tenant": "tenant_id",
    "created_at": 423423432,
    "created_by": 333,
    "updated_at": 423423432,
    "updated_by": 333,
    "name": "Brake Pad",
    "type": "brakes",
    "key_a": "value_a",
    "key_b": "value_b",
    "key_c": "value_c"
}

Create Part

Add a new part to the system.

Endpoint: /_a/part

Method: POST

Headers:

  • Authorization: Bearer <access_token>
  • Content-Type: multipart/form-data

Form Parameters:

  • json: JSON string containing part details
    {
        "name": "Cable RT",
        "type": "cable",
        "key_a": "value_a",
        "key_b": "value_b",
        "key_c": "value_c",
    }
    
    Other than name & type, rest of the fields in the payload (such as key_a, key_b & key_c in the above sample) will be read as the specification for the part. The key should match the key specified in the part_type_write.yml used for tenant configuration.
  • <file_name>: File attachment for the part. The key <file_name> should match one of the keys specified in the part_type_write.yml as the file attachment for the part.

Sample Success Response: - Code: 200 OK

{
    "id": "124",
    "tenant": "tenant_id",
    "created_at": 423423432,
    "created_by": 333,
    "updated_at": 423423432,
    "updated_by": 333,
    "name": "Cable RT",
    "type": "cable",
    "key_a": "value_a",
    "key_b": "value_b",
    "key_c": "value_c",
}

Update Part

Update an existing part's information.

Endpoint: /_a/part/{part_id}

Method: PUT

Headers:

  • Authorization: Bearer <access_token>
  • Content-Type: multipart/form-data

Form Parameters:

  • json: JSON string containing part details
    {
        "name": "Updated Cable RT",
        "type": "cable",
        "key_a": "new_value_a",
        "key_b": "new_value_b",
        "key_c": "new_value_c"
    }
    
    Other than name & type, rest of the fields in the payload (such as key_a, key_b & key_c in the above sample) will be read as the specification for the part. The key should match the key specified in the part_type_write.yml used for tenant configuration.
  • <file_name>: File attachment for the part. The key <file_name> should match one of the keys specified in the part_type_write.yml as the file attachment for the part.

Success Response: - Code: 200 OK

{
    "id": "124",
    "tenant": "tenant_id",
    "created_at": 423423432,
    "created_by": 333,
    "updated_at": 423423432,
    "updated_by": 333,
    "name": "Updated Cable RT",
    "type": "cable",
    "key_a": "new_value_a",
    "key_b": "new_value_b",
    "key_c": "new_value_c"
}

Delete Part

Remove a part from the system.

Endpoint: /_s/part/{part_id}

Method: DELETE

Headers:

  • Authorization: Bearer <access_token>

Success Response:

  • Code: 200 OK
    {}
    

Error Responses

All endpoints may return these error responses:

  • 401 Unauthorized:

    {
        "error": "Invalid or expired token"
    }
    

  • 403 Forbidden:

    {
        "error": "Insufficient permissions"
    }
    

  • 404 Not Found:

    {
        "error": "Part not found"
    }
    

  • 422 Unprocessable Entity:

    {
        "error": "Validation failed",
        "details": {
            "price": "Must be greater than 0"
        }
    }
    

Example Usage

Create Part

curl -X POST https://api.example.com/v1/parts \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
  -F "payload={\"name\":\"New Brake Pad\",\"category\":\"Brakes\",\"price\":49.99,\"stock\":100}" \
  -F "images[]=@brake-pad-front.jpg" \
  -F "images[]=@brake-pad-back.jpg" \
  -F "manual=@installation-guide.pdf" \
  -F "datasheet=@technical-specs.pdf"

Update Part

curl -X PUT https://api.example.com/_a/part/124 \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..." \
  -F "json={\"name\":\"Updated Cable RT\",\"type\":\"cable\",\"key_a\":\"new_value_a\",\"key_b\":\"new_value_b\"}" \
  -F "manual=@new-installation-guide.pdf" \
  -F "datasheet=@new-specs.pdf"