{"openapi":"3.0.3","info":{"title":"Simple Green Solutions API","version":"1.0.0","description":"Partner API for pharmacies, stock, registered medicines and booking. For server-to-server use: API keys must never reach a browser. Limit: 60 requests a minute per API key. Branch on the `code` in an error, not its English `message`."},"servers":[{"url":"https://www.sgreensolutions.com/api/v1"},{"url":"https://api.sgreensolutions.com/v1"}],"security":[{"apiKey":[]}],"paths":{"/oauth/token":{"post":{"operationId":"exchangeCode","summary":"Swap a patient's one-time code for an access token","description":"Send the patient to https://www.sgreensolutions.com/oauth/authorize with client_id, redirect_uri, response_type=code, code_challenge, code_challenge_method=S256 and state. After they approve, the code arrives at redirect_uri. Requires the appointments:write scope. Tokens last 15 minutes and there is no refresh token.","requestBody":{"required":true,"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","required":["grant_type","code","redirect_uri","code_verifier"],"properties":{"grant_type":{"type":"string","enum":["authorization_code"]},"code":{"type":"string"},"redirect_uri":{"type":"string"},"code_verifier":{"type":"string"}}}}}},"responses":{"200":{"description":"The token","content":{"application/json":{"schema":{"type":"object","required":["access_token","token_type","expires_in","scope"],"properties":{"access_token":{"type":"string"},"token_type":{"type":"string","enum":["Bearer"]},"expires_in":{"type":"integer","description":"Seconds"},"scope":{"type":"string"}}}}}},"400":{"description":"Invalid request, or a code that is invalid, expired or already used","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Credentials lack the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached; see the Retry-After header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Tokens can't be issued right now","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/me/providers":{"get":{"operationId":"listMyProviders","summary":"List doctors at the signed-in patient's hospitals","security":[{"patientToken":[]}],"parameters":[{"name":"q","in":"query","schema":{"type":"string"},"description":"Matches the name"},{"name":"department","in":"query","schema":{"type":"string"}},{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"pageSize","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"One page of results","content":{"application/json":{"schema":{"type":"object","required":["data","page","pageSize","total"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Provider"}},"page":{"type":"integer"},"pageSize":{"type":"integer"},"total":{"type":"integer"}}}}}},"400":{"description":"Invalid paging","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Credentials lack the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached; see the Retry-After header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/me/providers/{id}/slots":{"get":{"operationId":"listMyProviderSlots","summary":"List a doctor's open slots on one day","description":"`date` is a day on the clinic's calendar.","security":[{"patientToken":[]}],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}},{"name":"date","in":"query","required":true,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"Open slots","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProviderSlots"}}}},"400":{"description":"Invalid date","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Credentials lack the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such provider at the patient's hospitals","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached; see the Retry-After header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/appointments":{"post":{"operationId":"createAppointment","summary":"Request an appointment for the signed-in patient","description":"The patient must be registered with the provider's hospital. The appointment starts as PENDING until staff approve it.","security":[{"patientToken":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["providerId","scheduledAt","type","consultationMode"],"properties":{"providerId":{"type":"string"},"scheduledAt":{"type":"string","format":"date-time","description":"A startsAt value from the slots endpoint"},"type":{"type":"string","enum":["ROUTINE","FOLLOW_UP","EMERGENCY","OPD"]},"consultationMode":{"type":"string","enum":["IN_PERSON","VIDEO"]},"reason":{"type":"string","maxLength":1000,"nullable":true}}}}}},"responses":{"201":{"description":"Requested","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Appointment"}}}},"400":{"description":"Invalid field","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Credentials lack the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such provider","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The slot is not open","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached; see the Retry-After header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/products":{"get":{"operationId":"listProducts","summary":"Search pharmacy products","description":"Requires the catalog:read scope.","parameters":[{"name":"q","in":"query","schema":{"type":"string"},"description":"Matches the product name"},{"name":"category","in":"query","schema":{"type":"string"},"description":"Category id"},{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"pageSize","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"One page of results","content":{"application/json":{"schema":{"type":"object","required":["data","page","pageSize","total"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Product"}},"page":{"type":"integer"},"pageSize":{"type":"integer"},"total":{"type":"integer"}}}}}},"400":{"description":"Invalid paging","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Credentials lack the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached; see the Retry-After header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/products/{id}":{"get":{"operationId":"getProduct","summary":"Get one pharmacy product","description":"Requires the catalog:read scope.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The product","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Product"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Credentials lack the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such product","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached; see the Retry-After header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/inventory":{"get":{"operationId":"listInventory","summary":"Check availability and price per pharmacy","description":"Requires the catalog:read scope. Exact quantities are never returned.","parameters":[{"name":"pharmacyId","in":"query","schema":{"type":"string"}},{"name":"q","in":"query","schema":{"type":"string"},"description":"Matches the product name"},{"name":"category","in":"query","schema":{"type":"string"},"description":"Category id"},{"name":"inStock","in":"query","schema":{"type":"boolean"},"description":"Only items with stock"},{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"pageSize","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"One page of results","content":{"application/json":{"schema":{"type":"object","required":["data","page","pageSize","total"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/InventoryItem"}},"page":{"type":"integer"},"pageSize":{"type":"integer"},"total":{"type":"integer"}}}}}},"400":{"description":"Invalid filter","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Credentials lack the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached; see the Retry-After header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/pharmacies":{"get":{"operationId":"listPharmacies","summary":"List pharmacies on PharmaStock","description":"Requires the catalog:read scope.","parameters":[{"name":"q","in":"query","schema":{"type":"string"},"description":"Matches the name"},{"name":"city","in":"query","schema":{"type":"string"}},{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"pageSize","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"One page of results","content":{"application/json":{"schema":{"type":"object","required":["data","page","pageSize","total"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Pharmacy"}},"page":{"type":"integer"},"pageSize":{"type":"integer"},"total":{"type":"integer"}}}}}},"400":{"description":"Invalid paging","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Credentials lack the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached; see the Retry-After header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/medications":{"get":{"operationId":"listMedications","summary":"Search medicines authorised for sale in Côte d'Ivoire","description":"Requires the catalog:read scope. Source: the AIRP register, refreshed daily.","parameters":[{"name":"q","in":"query","schema":{"type":"string"},"description":"Matches the name or active ingredient"},{"name":"page","in":"query","schema":{"type":"integer","minimum":1,"default":1}},{"name":"pageSize","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}}],"responses":{"200":{"description":"One page of results","content":{"application/json":{"schema":{"type":"object","required":["data","page","pageSize","total"],"properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Medication"}},"page":{"type":"integer"},"pageSize":{"type":"integer"},"total":{"type":"integer"}}}}}},"400":{"description":"Invalid paging","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid credentials","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Credentials lack the required scope","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit reached; see the Retry-After header","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"A partner API key (sgs_live_...)"},"patientToken":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"From /oauth/token"}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["code","message"],"properties":{"code":{"type":"string"},"message":{"type":"string"}}}}},"Product":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"price":{"type":"number"},"currency":{"type":"string"},"dosage":{"type":"string","nullable":true},"category":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}},"nullable":true},"pharmacy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}}},"stockStatus":{"type":"string","enum":["IN_STOCK","LOW_STOCK","CRITICAL","NOT_AVAILABLE"]},"available":{"type":"boolean"}}},"InventoryItem":{"type":"object","properties":{"productId":{"type":"string"},"productName":{"type":"string"},"pharmacy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}}},"price":{"type":"number"},"currency":{"type":"string"},"stockStatus":{"type":"string","enum":["IN_STOCK","LOW_STOCK","CRITICAL","NOT_AVAILABLE"]},"available":{"type":"boolean"}}},"Pharmacy":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"address":{"type":"object","nullable":true,"properties":{"street":{"type":"string"},"city":{"type":"string"},"state":{"type":"string","nullable":true},"postalCode":{"type":"string","nullable":true},"country":{"type":"string"}}},"phone":{"type":"string","nullable":true},"onlineOrdersEnabled":{"type":"boolean"}}},"Medication":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"activeIngredients":{"type":"string","nullable":true},"authorizationNumber":{"type":"string"},"laboratory":{"type":"string","nullable":true},"countryOfOrigin":{"type":"string","nullable":true},"authorizedOn":{"type":"string","format":"date-time","nullable":true},"authorizedUntil":{"type":"string","format":"date-time"},"documents":{"type":"object","properties":{"productCharacteristics":{"type":"string","nullable":true},"patientLeaflet":{"type":"string","nullable":true}}}}},"Provider":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"specialization":{"type":"string"},"designation":{"type":"string"},"department":{"type":"string"},"bio":{"type":"string"},"languages":{"type":"array","items":{"type":"string"}},"yearsOfExperience":{"type":"number"},"rating":{"type":"number"},"reviewCount":{"type":"integer"},"consultationFee":{"type":"number","nullable":true},"currency":{"type":"string"},"organization":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"}}}}},"ProviderSlots":{"type":"object","properties":{"providerId":{"type":"string"},"date":{"type":"string","format":"date"},"timezone":{"type":"string"},"consultationFee":{"type":"number","nullable":true},"slots":{"type":"array","items":{"type":"object","properties":{"startsAt":{"type":"string","format":"date-time"},"durationMinutes":{"type":"integer"}}}}}},"Appointment":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string"},"scheduledAt":{"type":"string","format":"date-time"},"durationMinutes":{"type":"integer"},"type":{"type":"string"},"consultationMode":{"type":"string"},"providerId":{"type":"string"},"organizationId":{"type":"string"}}}}}}