0% found this document useful (0 votes)
4 views2 pages

REST API Assignment Document

The document outlines a phased REST API assignment focused on counter management and token lifecycle management, including expiration. Phase 1 involves creating an API to increment a counter, Phase 2 covers token creation and closure, and Phase 3 introduces expiring tokens with automatic deletion. Each phase includes specific endpoints and success responses for various operations related to counters and tokens.

Uploaded by

dhirajspocket
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

REST API Assignment Document

The document outlines a phased REST API assignment focused on counter management and token lifecycle management, including expiration. Phase 1 involves creating an API to increment a counter, Phase 2 covers token creation and closure, and Phase 3 introduces expiring tokens with automatic deletion. Each phase includes specific endpoints and success responses for various operations related to counters and tokens.

Uploaded by

dhirajspocket
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

REST API Development Assignment

This document describes a phase-wise REST API assignment covering counter management and token lifecycle
management, including timeout-based expiration.

Phase 1 – Counter Increment API


Objective: Create an API that increments a counter on each request and returns the updated counter value.

Endpoint
POST /v1/counter/increment
Request Payload
{}
Success Response
{ "message": "Counter incremented successfully", "counter": 5, "timestamp": "2026-01-08T10:15:30Z" }

Phase 2 – Token Management (Without Expiry)


This phase introduces token creation, uniqueness validation, and manual token closure.

Create Token API


POST /v1/tokens
Request Payload
{ "serviceRequestId": "SR-12345", "requestType": "INSTALLATION", "requestedBy": "userA" }
Success Response
{ "message": "Token created successfully", "tokenNumber": "TKN-000001", "serviceRequestId": "SR-12345", "status": "OPEN",
"createdAt": "2026-01-08T10:20:00Z" }
Token Already Exists Response
{ "message": "Token already exist", "existingTokenNumber": "TKN-000001", "status": "OPEN", "timestamp":
"2026-01-08T10:20:10Z" }
Close Token API
POST /v1/tokens/{tokenNumber}/close
Close Token Success Response
{ "message": "Token closed successfully", "tokenNumber": "TKN-000001", "status": "CLOSED", "closedAt":
"2026-01-08T10:30:00Z" }

Phase 3 – Token Management with Timeout and Auto Deletion


This phase extends token handling by introducing a fixed timeout and automatic deletion after expiration.

Create Expiring Token API


POST /v1/expiring-tokens
Request Payload
{ "serviceRequestId": "SR-77777", "requestType": "REPAIR", "requestedBy": "userB" }
Success Response
{ "message": "Token created successfully", "tokenNumber": "ETKN-000001", "serviceRequestId": "SR-77777", "status": "OPEN",
"createdAt": "2026-01-08T11:00:00Z", "timeoutSeconds": 20, "expiresAt": "2026-01-08T11:00:20Z" }
Close and Delete Token API
POST /v1/expiring-tokens/{tokenNumber}/close
Expired Token Response
{ "message": "Token does not exist", "tokenNumber": "ETKN-000001", "timestamp": "2026-01-08T11:00:25Z" }

Summary of APIs
Phase Description Endpoint
1 Increment Counter /v1/counter/increment
2 Create Token /v1/tokens
2 Close Token /v1/tokens/{token}/close
3 Create Expiring Token /v1/expiring-tokens
3 Close & Delete Token /v1/expiring-tokens/{token}/close

You might also like