> ## Documentation Index
> Fetch the complete documentation index at: https://developer.sakari.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup autotopup for your account



## OpenAPI

````yaml api-reference/generated.yaml post /v1/accounts/{accountId}/attributes/{attributeType}
openapi: 3.1.0
info:
  description: >
    # Introduction


    Welcome to the documentation for the Sakari Messaging REST API. 


    Sakari provides an advanced platform to drive large scale customized SMS
    communication


    REST is a web-service protocol that lends itself to rapid development by
    using everyday HTTP and JSON technology.


    To find out more about our product offering, please visit
    [https://sakari.io](https://sakari.io).


    # Quickstart


    For your convenience we have created a quickstart guide to get you up and
    running in 5 minutes. 


    [https://sakari.io/blog/text-messaging-sms-api-quickstart/](https://sakari.io/blog/text-messaging-sms-api-quickstart/)


    # PostMan Collection


    We've created a simple set of examples using
    [PostMan](https://www.getpostman.com/) Simply click below to import these.
    You will need to setup three environment variables in PostMan - AccountId,
    ClientId and ClientSecret. Check out our PostMan blog post for more
    information


    [![Run in
    Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/d616e273edc916a7a6eb)


    # Finding your client id, client secret and account id


    To authenticate against the API's you will need three key pieces of data
     - client id
     - client secret
     - account id

    To retrieve these, simply login into
    [https://hub.sakari.io](https://hub.sakari.io) and click on the "cog" in the
    top right corner. In the popup dialog at the bottom you should see your API
    credentials and account id. If these are not visible you will need to click
    on "Request Credentials"


    # Versioning


    With any breaking changes we will introduce a new version of the API. The
    latest version is v1.


    The API uses an open schema model, which means server may add extra
    properties to responses. Likewise, the server will ignore any extra query
    parameters and request body properties. When you write clients, you need to
    ignore additional properties in responses to ensure they do not break.


    # Testing


    There are numerous tools available for testing the API's. We will include
    examples using curl and the client SDKs that we have created. If you would
    like to see an SDK in a language not currently available, please let us
    know.


    # Throttling / Limits


    Our API's have been specifically designed to support bulk messaging in a
    single API call. We therefore impose limits on the frequency of calling the
    APIs to prevent abuse or runaway processes. If you feel you need a higher
    limit, please contact us. If you hit the limit you will get a 429 error code
    returned from our servers


    # Errors


    The API uses standard HTTP status codes to indicate the success or failure
    of the API call. The body of the response will be JSON in the following
    format:


    ```

    {
      "success": false,
      "error": {
        "code": "CONT-001",
        "message": "Invalid mobile number"
      }
    }

    ```


    # Pagination


    For performance, most GET calls return a subset of data. This data is
    paginated for easy access. Most APIs which return collections of data will
    return a pagination object as such:


    ```

    {
      "pagination": {
        "offset": 0,
        "limit": 10
      }  
    }

    ```


    When making calls to the API, you can adjust the slice of data returned
    using query parameters such as:


    `` https://api.sakari.io/v1/accounts/123/contacts?offset=20&limit=25 ``


    This will return 25 contacts with an offset of 20.
  version: 1.0.2
  title: Sakari
  termsOfService: https://sakari.io/terms-service.html
  contact:
    email: help@sakari.io
servers:
  - description: Sakari Production
    url: https://api.sakari.io
security: []
tags:
  - name: authentication
    description: >
      Sakari uses OAuth2 for authentication. After you have created an account
      at [https://hub.sakari.io](https://hub.sakari.io), you can retrieve your
      client id and secret from the 'Account Details' screen (click on the 'cog'
      icon in the top right corner and scroll down to API Credentials)


      Using your client id and secret, you can exchange these for a JWT ([JSON
      Web Token](https://en.wikipedia.org/wiki/JSON_Web_Token))


      The JWT should then be used when accessing any of the core API's. It
      should be passed in the `Authorization` header.


      For example:


      ``Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImt....``
  - name: accounts
    description: Create, modify or delete accounts
  - name: contacts
    description: Create, modify or delete contacts
  - name: integrations
    description: View existing integrations in your Sakari account
  - name: autoresponders
    description: Create, modify, or delete autoresponders
  - name: availablephonenumbers
    description: Check for available phone numbers
  - name: bulk
    description: Bulk actions for contacts and users
  - name: messages
    description: >-
      Send or track messages to one contact, a group of contacts or your entire
      address book
  - name: templates
    description: Define reusable message or web templates
  - name: campaigns
    description: >-
      Define reusable message campaigns with a predefined contact list/filter,
      template and schedule
  - name: conversations
    description: Conversations group your message history with each contact into one thread
  - name: tools
    description: >-
      Tools to assist with sending and receiving messages, such as file sharing,
      translation, etc.
  - name: webhooks
    description: >-
      Webhooks allow your own system to be automatically notified upon certin
      events, such as a new message received from one of your contacts or a
      status change notification for your messages
  - name: workflows
    description: Create, modify, and delete workflows
  - name: workflowtemplates
    description: Existing workflow templates that can be used
  - name: meetingevents
    description: Configure meeting events for your leads to book time with you
  - name: meetings
    description: Meetings with your contacts
externalDocs:
  description: Find out more about Sakari
  url: https://sakari.io
paths:
  /v1/accounts/{accountId}/attributes/{attributeType}:
    post:
      tags:
        - accounts
      summary: Setup autotopup for your account
      operationId: account.attributes.create
      parameters:
        - $ref: '#/components/parameters/accountIdPath'
        - $ref: '#/components/parameters/attributeTypePath'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Contact'
          text/csv:
            schema:
              type: string
              example: >
                country,firstName,lastName,email,mobile,jobTitle,Address,City,State,ZipCode
                US,Joe,Bloggs,joebloggs@sakari.co,123-456-7890,mover,123 Text
                Street,San Francisco,CA,12345
      responses:
        '200':
          description: successful operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AutoTopupResponse'
        4XX:
          $ref: '#/components/responses/4XX'
        5XX:
          $ref: '#/components/responses/5XX'
      security:
        - sakari_auth: []
components:
  parameters:
    accountIdPath:
      name: accountId
      in: path
      description: Account to apply operations to
      required: true
      schema:
        type: string
    attributeTypePath:
      name: attributeType
      in: path
      description: Type of custom attribute
      required: true
      schema:
        type: string
        enum:
          - contacts
          - deals
          - tickets
  schemas:
    Contact:
      allOf:
        - $ref: '#/components/schemas/Person'
        - type: object
          properties:
            lists:
              type: array
              items:
                $ref: '#/components/schemas/ContactList'
            attributes:
              type: object
            optIn:
              type: string
              format: date-time
            blocked:
              type: string
              format: date-time
            activecampaign:
              type: object
              properties:
                id:
                  type: number
            hubspot:
              type: object
              properties:
                id:
                  type: number
            pipedrive:
              type: object
              properties:
                id:
                  type: number
            valid:
              type: boolean
              readOnly: true
            error:
              $ref: '#/components/schemas/Error'
            created:
              $ref: '#/components/schemas/Updated'
              readOnly: true
            updated:
              $ref: '#/components/schemas/Updated'
              readOnly: true
      required:
        - id
    AutoTopupResponse:
      allOf:
        - $ref: '#/components/schemas/BasicResponse'
        - type: object
          properties:
            data:
              $ref: '#/components/schemas/AutoTopup'
      required:
        - data
    Person:
      type: object
      properties:
        id:
          type: string
          readOnly: true
        email:
          type: string
          example: chris@sakari.io
        firstName:
          type: string
          example: Chris
        lastName:
          type: string
          example: Bloggs
        mobile:
          $ref: '#/components/schemas/InternationalNumber'
    ContactList:
      allOf:
        - $ref: '#/components/schemas/List'
        - type: object
          properties:
            optIn:
              type: string
              format: date-time
            optOut:
              type: string
              format: date-time
    Error:
      type: object
      properties:
        code:
          type: string
          example: CONT-010
        description:
          type: string
          example: Contact has requested no further communication
      required:
        - code
        - description
    Updated:
      type: object
      properties:
        at:
          type: string
          format: date-time
        by:
          $ref: '#/components/schemas/UpdatedBy'
      readOnly: true
      required:
        - at
    BasicResponse:
      type: object
      properties:
        success:
          type: boolean
      required:
        - success
    AutoTopup:
      type: object
      required:
        - amount
        - below
      properties:
        amount:
          type: number
        below:
          type: number
        lastTopup:
          type: string
          format: date-time
    ErrorResponse:
      allOf:
        - $ref: '#/components/schemas/BasicResponse'
        - type: object
          properties:
            error:
              $ref: '#/components/schemas/Error'
      required:
        - error
    InternationalNumber:
      type: object
      properties:
        country:
          type: string
        number:
          type: string
          example: 123-456-7890
        verified:
          type: string
          format: date-time
        valid:
          type: boolean
        lineType:
          type: string
          example: mobile
      required:
        - country
        - number
    List:
      type: object
      properties:
        id:
          type: string
          readOnly: true
        name:
          type: string
        source:
          type: object
          properties:
            id:
              type: string
            integration:
              type: string
            lastSynced:
              type: string
          required:
            - id
            - integration
        keyword:
          type: string
        doubleOptIn:
          type: object
          properties:
            enabled:
              type: boolean
            prompt:
              type: string
        filter:
          $ref: '#/components/schemas/ContactFilter'
        optInConfirmation:
          type: string
      required:
        - id
        - name
    UpdatedBy:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
          example: Joe Bloggs
        firstName:
          type: string
          example: Joe
        lastName:
          type: string
          example: Bloggs
        email:
          type: string
          example: joe@bloggs.com
        source:
          type: string
        subSource:
          type: string
    ContactFilter:
      type: object
      properties:
        q:
          type: string
        attributes:
          type: array
          items:
            $ref: '#/components/schemas/Condition'
        list:
          type: string
        valid:
          type: boolean
        invalid:
          type: boolean
        blocked:
          type: boolean
        unblocked:
          type: boolean
        optIn:
          type: boolean
    Condition:
      type: object
      properties:
        attribute:
          type: string
        comparator:
          type: string
        value:
          oneOf:
            - type: array
              items:
                type: string
            - type: array
              items:
                type: number
            - type: string
            - type: number
      required:
        - attribute
        - comparator
        - value
  responses:
    4XX:
      description: invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    5XX:
      description: invalid request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    sakari_auth:
      type: oauth2
      flows:
        clientCredentials:
          tokenUrl: /oauth2/token
          scopes:
            messages:send: Send messages

````