Skip to content

Instantly share code, notes, and snippets.

@nwgambee
Last active October 26, 2021 15:25
Show Gist options
  • Save nwgambee/6470b31de76f7c819ad451e38b0be175 to your computer and use it in GitHub Desktop.
Save nwgambee/6470b31de76f7c819ad451e38b0be175 to your computer and use it in GitHub Desktop.
CP CWP Call + Response Requests

CarePenguin Customer Web Portal New Calls

Endpoint for a user to hit when they deactivate their own account from the CWP

Method: DELETE 
Path: /user/:user_id/delete (Nick has set this up, check swagger)
Content-Type: application/json
Body: {}

Responses:

  • 403 failed to deactivate
{ 
result: { errors: [ 'Failed to deactivate account' ] } 
}

Create-user/sign-up endpoint for use on CWP Create User form submission (including validation of emailed magic link)

Submit initial form

Method: POST 
Path: /user/create
Content-Type: application/json
Body: JSON.stringify({
        name: 'Noah Gambee',
        email: '[email protected]',
        phone: '3035557866',
        password: 'ilovepizza789'
      }),

Responses:

  • 200 Success
{ 
result: { data: { userId: 123 }}
}
  • 403 Email in use
{ 
result: { errors: [ 'Email already in use by another account' ] } 
}

Validate new user through emailed link

Method: POST 
Path: /user/create/validate
Content-Type: application/json
Body: JSON.stringify({
        magicLinkId: 'FH367NEYX4H',
        userId: 49
      }),

Responses:

  • 200 Success
{ 
result: { data: { userId: 123 }}
}
  • 403 Validation failed
{ 
result: { errors: [ 'Validation failed', '{reason for failure}' ] } 
}

Endpoint for user to edit their own account details ie: email/phone/name (Nick has already done this one)

Method: PATCH 
Path: /user/:id
Content-Type: application/json-patch+json
Body: {
"patches" : [
  {
    "op" : "replace",
    "path" : "/email",
    "value" : "[email protected]"
  },
  {
    "op" : "replace",
    "path" : "/phone",
    "value" : "3035558739"
  }
 ]
}

Responses:

  • 403 failed to edit
{ 
result: { errors: [ 'email already in use by another account' ] } 
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment