Users

The User resource type represents an individual CodeGuard account. This API can only be used to create and delete users.

Context

Requests to the User resource can only be made by authenticated partners. The api_key parameter must be passed with every request and contain a valid Partner API Key.

Attributes

The following are the attributes associated with the User resource. Whether they are required or optional is specified in the sections that follow.

name

The individuals full name. This is used for salutations in email communication and display in the application interface.

email

The email address to be associated with this account. Email is used for logging in to the application interface as well as communication.

password

The password associated with the user account. For partners that do not permit direct-login to the CodeGuard application this attribute is not supported. Note: This can only be specified during user creation. It is never returned in a response and it is not accepted in other contexts.

time_zone

The text representation of the desired time zone to use for displaying time and date data. A list of supported time zones is included in the appendix at the end of this document.

id

Unique numeric ID used to identify the user resource in the CodeGuard application.

size

The account size in bytes of the user resource.

access_token

User-specific OAuth access token for CodeGuard API access. Note: These values are only returned after the user creation request. They are not settable using this API and they are never returned as part of the user resource after creation.

access_secret

User-specific OAuth secret for CodeGuard API access. Note: These values are only returned after the user creation request. They are not settable using this API and they are never returned as part of the user resource after creation.

api_key

User-specific OAuth access token for CodeGuard API access. Note: These values are only returned after the user creation request. They are not settable using this API and they are never returned as part of the user resource after creation.

api_secret

User-specific OAuth secret for CodeGuard API access. Note: These values are only returned after the user creation request. They are not settable using this API and they are never returned as part of the user resource after creation.

partner_data

This is a flexible text field that can be used for partners to store user-specific information they may need to identify the user.

plan_id

The plan_id represents the CodeGuard plan associated with the user. The plan dictates the features and limits that govern the User account.

active

This field indicates if the User account is enabled and functional (true) or has been suspended (false).

search

This attribute is used to search user accounts by name or email address.

page

If you have a large set of users, this parameter is used to paginate records and show you the Nth page of records.

Create Users

This method is used to create new CodeGuard users.

URI: /users

Method: POST

Required Attributes

The request will not succeed without these attributes.

Optional Attributes
Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST -d '{"user" : {"name" : "A User", "email" : "first.lastname@co.com", "partner_data" : "{\"package_id\":\"ppp-123456\"}"}}' https://api.codeguard.com/users?api_key=012c513e6d309c158a19bcbc86bb7a88
        
Example Response
{
            "user": {
                "id":39763,
                "name":"A User",
                "email":"first.lastname@co.com",
                "access_secret":"HRzHGqskj3DNdOCYbPDv92HYKplwW6PyESEl8cwB",
                "api_secret":"1H3kUaaIj5LiGvICDUiOR2aQC8mYkV6MPMsX6xMG",
                "api_key":"u1xe85RrWhpJim3xslJb9GI9ENms6PmFjYDeTOgc",
                "access_token":"qFFTIQszYZwHc4KmeZciyFjHT9XdcsRGrgkgwPQr",
                "time_zone":"UTC",
                "partner_data" : "{\"package_id\":\"ppp-123456\"}",
                "plan_id":88
            }
        }
        

List Users

URI: /users/<USER ID>

Method: GET

Required Attributes

The request will not succeed without these attributes.

Required Attributes
Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X GET https://api.codeguard.com/users/48767?api_key=012c513e6d309c158a19bcbc86bb7a88
        
Example Response
{
            "user": {
                "name":"A User",
                "size":12374124,
                "partner_data":"{\"package_id\":\"ppp-123456\"}",
                "id":8,
                "time_zone":"UTC",
                "email":"user@example.com",
                "plan_id":88
            }
        }
        

Delete Users

This method is used to delete existing CodeGuard users that were created by a Partner. Parters can not delete users created by other partners. Deleting a user resource will also delete all associated Website and Database records.

URI: /users/<id>

Method: DELETE

Required Attributes
Optional Attributes

None

Example Request
curl -i -X DELETE https://api.codeguard.com/users/377?api_key=3a912fdd3c8657584aa8f4bbb1bce174
        

Change User Plan

This method is used to change the Plan associated with an existing CodeGuard user. Only partners may perform this action, users can not change their own plan. You must specify a plan_id attribute which represents the integer ID of a CodeGuard plan.

Note: Specifying a plan_id that is already set for the user in question will result in a 403 (Forbidden) response.

URI: /users/<id>/plan

Method: POST

Required Attributes
Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST https://api.codeguard.com/users/48767/plan?api_key=012c513e6d309c158a19bcbc86bb7a88&plan_id=99
        
Example Response
{
            "user": {
                "name":"A User",
                "size":12374124,
                "partner_data":"{\"package_id\":\"ppp-123456\"}",
                "id":8,
                "time_zone":"UTC",
                "email":"user@example.com",
                "plan_id":99
            }
        }
        

Suspend User Account

This method is used to disable a CodeGuard user. Only partners may perform this action, users can not disable their own account. After suspension all backups will be disabled and the user will not be permitted to login.

URI: /users/<id>/suspend

Method: POST

Required Attributes
Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST https://api.codeguard.com/users/48767/suspend?api_key=012c513e6d309c158a19bcbc86bb7a88
Example Response
{
            "user": {
                "name":"A User",
                "size":12374124,
                "active":false,
                "partner_data":"{\"package_id\":\"ppp-123456\"}",
                "id":8,
                "time_zone":"UTC",
                "email":"user@example.com",
                "plan_id":99
            }
        }
        

Reactivate User Account

This method is used to re-enable a suspended CodeGuard user. Only partners may perform this action, users can not reactivate their own account. All backups will be re-enabled and the user will be permitted to login.

URI: /users/<id>/reactivate

Method: POST

Required Attributes
Optional Attributes

None

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X POST https://api.codeguard.com/users/48767/reactivate?api_key=012c513e6d309c158a19bcbc86bb7a88
Example Response
{
            "user": {
                "name":"A User",
                "size":12374124,
                "active":true,
                "partner_data":"{\"package_id\":\"ppp-123456\"}",
                "id":8,
                "time_zone":"UTC",
                "email":"user@example.com",
                "plan_id":99
            }
        }
        

List All Users

URI: /users

Method: GET

Required Attributes
Optional Attributes

page - The page number

per_page - The number of results per page

sort - See below

Sorting Options

created/-created - Sort the users by their creation date

name/-name - Sort the users alphabetically by name

Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X GET https://api.codeguard.com/users?api_key=012c513e6d309c158a19bcbc86bb7a88
        
Example Response
[
        {
            "user": {
                "name":"A User",
                "size":12374124,
                "partner_data":"{\"package_id\":\"ppp-123456\"}",
                "id":8,
                "time_zone":"UTC",
                "email":"user@example.com",
                "plan_id":88
            }
        },
        {
            "user": {
                "name":"Another User",
                "size":12374124,
                "partner_data":"{\"package_id\":\"ppp-123456\"}",
                "id":8,
                "time_zone":"UTC",
                "email":"another.user@example.com",
                "plan_id":88
            }
        }]
        

Search User

URI: /users?search=<QUERY STRING>

Method: GET

Required Attributes
Optional Attributes
Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X GET https://api.codeguard.com/users?api_key=012c513e6d309c158a19bcbc86bb7a88?search=Another
        
Example Response
[{
          "user": {
              "name":"Another User",
              "size":12374124,
              "partner_data":"{\"package_id\":\"ppp-123456\"}",
              "id":8,
              "time_zone":"UTC",
              "email":"another.user@example.com",
              "plan_id":88
          }
      }]
        
Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -X GET https://api.codeguard.com/users?api_key=012c513e6d309c158a19bcbc86bb7a88?search=another.user@example.com
        
Example Response
[{
          "user": {
              "name":"Another User",
              "size":12374124,
              "partner_data":"{\"package_id\":\"ppp-123456\"}",
              "id":8,
              "time_zone":"UTC",
              "email":"another.user@example.com",
              "plan_id":88
          }
      }]
        

Edit User

URI: /users/<USER ID>

Method: PUT

Required Attributes
Optional Attributes
Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -d '{"user": {"name" : "New Name" }}' -X POST https://api.codeguard.com/users/3?api_key=012c513e6d309c158a19bcbc86bb7a88
        
Example Response
{
            "user": {
                "name":"New Name",
                "size":12374124,
                "partner_data":"{\"package_id\":\"ppp-123456\"}",
                "id":8,
                "time_zone":"UTC",
                "email":"user@example.com",
                "plan_id":88
            }
        }
        

Create User

URI: /users

Method: POST

Required Attributes
Optional Attributes
Example Request
curl -v -H "Content-type: application/json" -H "Accept: application/json" -d '{"user": {"name" : "Test Account", "email" : "test.account@example.com", "password" : "toosimpletoguess", "password_confirmation" : "toosimpletoguess" }}' -X POST https://api.codeguard.com/users?api_key=012c513e6d309c158a19bcbc86bb7a88
        
Example Response

        { "request": { "act": null },
          "response": {
            "user_email": "test.account@example.com",
            "user_zone": null,
            "service_url":"https://codeguard.com/" }
          "result": "success",
          "msg": "Your CodeGuard account has been successfully created.  You will receive an email with your login information shortly."
        }