# Update Account

You'll submit the account information to be processed on Wyre. The `status` field is then going to be updated to either **OPEN** | **PENDING** | **APPROVED**. We provide a `note` field, which will provide guidance on resolving the issue.

| Status   | Description                | Example                                  |
| -------- | -------------------------- | ---------------------------------------- |
| OPEN     | Awaiting action from user. | Expired document, awaiting resubmission. |
| PENDING  | Awaiting action from Wyre. | Processing on Wyre.                      |
| APPROVED | No further action needed.  | Document successfully verified.          |

## Update Account

<mark style="color:green;">`POST`</mark> `https://api.sendwyre.com/v3/accounts/:accountId`

#### Path Parameters

| Name      | Type   | Description                            |
| --------- | ------ | -------------------------------------- |
| accountId | string | the ID of the Account you are updating |

{% tabs %}
{% tab title="200 " %}

```
{
  "id" : "AC-U4BWHGZDG6W",
  "status" : "PENDING",
  "type" : "INDIVIDUAL",
  "country" : "US",
  "createdAt" : 1541789972000,
  "depositAddresses" : {
    "ETH" : "0x98B031783d0efb1E65C4072C6576BaCa0736A912",
    "BTC" : "14CriXWTRoJmQdBzdikw6tEmSuwxMozWWq"
  },
  "totalBalances" : { 
    "BTC" : 1.0000000,
    "ETH" : 0.1000000000000000000
  },
  "availableBalances" : { 
    "BTC" : 1.0000000,
    "ETH" : 0.1000000000000000000
  },
  "profileData" : [ {
    "fieldId" : "individualCellphoneNumber",
    "fieldType" : "CELLPHONE",
    "value" : null,
    "note" : "Must be verified by user.",
    "status" : "OPEN"
  }, {
    "fieldId" : "individualEmail",
    "fieldType" : "EMAIL",
    "value" : "johnnyquest22@yolo.com",
    "note" : "Must be verified by user.",
    "status" : "OPEN"
  }, {
    "fieldId" : "individualLegalName",
    "fieldType" : "STRING",
    "value" : "Johnny Quest",
    "note" : null,
    "status" : "PENDING"
  }, {
    "fieldId" : "individualDateOfBirth",
    "fieldType" : "DATE",
    "value" : null,
    "note" : null,
    "status" : "OPEN"
  }, {
    "fieldId" : "individualSsn",
    "fieldType" : "STRING",
    "value" : null,
    "note" : null,
    "status" : "NULL"
  }, {
    "fieldId" : "individualResidenceAddress",
    "fieldType" : "ADDRESS",
    "value" : {
        "street1": "1 Market St",
        "street2": "Suite 402",
        "city": "San Francisco",
        "state": "CA",
        "postalCode": "94105",
        "country": "US"
    },
    "note" : null,
    "status" : "PENDING"
  }, {
    "fieldId" : "individualGovernmentId",
    "fieldType" : "DOCUMENT",
    "value" : [],
    "note" : null,
    "status" : "OPEN"
  }, {
    "fieldId" : "individualSourceOfFunds",
    "fieldType" : "PAYMENT_METHOD",
    "value" : null,
    "note" : "Payment method not yet submitted",
    "status" : "OPEN"
  } ]
}
```

{% endtab %}
{% endtabs %}

## Examples

{% tabs %}
{% tab title="JSON" %}

```go
{
  "profileFields": [{
    "fieldId": "individualLegalName",
    "value": "Johnny Quest"
  }, {
    "fieldId": "individualCellphoneNumber",
    "value": "+1 715-111-2222"
  }, {
    "fieldId": "individualEmail",
    "value": "lol@bananaphone.com"
  }, {
    "fieldId": "individualDateOfBirth",
    "value": "1990-09-24"
  }, {
    "fieldId": "individualResidenceAddress",
    "value": {
        "street1": "1 Market St",
        "street2": "Suite 420",
        "city": "San Francisco",
        "state": "CA",
        "postalCode": "94105",
        "country": "US"
      }
  }
  ]
}
```

{% endtab %}

{% tab title="Python" %}

```python
'''
This is a Python 3.7 Module that updates a Wyre Account
using secret key authentication.

You can only use this module for updating individual
or business accounts if you already have an account set up.

If you do not have a business or individual account with a secretKey/ApiKey,
go through the sign-up process for a test account here: https://www.testwyre.com/
'''

import hashlib
import hmac
import json
import os
import requests
import time
import urllib.parse


class WyreApi:
    ACCOUNT_ID = os.getenv("ACCOUNT_ID")
    API_KEY = os.getenv("WYRE_APIKEY")
    SEC_KEY = os.getenv("WYRE_TOKEN")
    API_VER3 = "/v3"
    API_ACCOUNT_PATH = "/accounts"
    API_URL = "https://api.testwyre.com"




    '''
        This method calculates the auth signature hash required for secret key 
        authentication
    '''

    def calc_auth_sig_hash(self, url_body):
        # calculates a signature per Wyre API:
        # https://docs.sendwyre.com/docs/authentication#secret-key-signature-auth
        message, secret = bytes(
            url_body, 'utf-8'), bytes(WyreApi.SEC_KEY, 'utf-8')
        newhash = hmac.new(secret, message, hashlib.sha256)
        return newhash.hexdigest()





    '''
        This method calculates a timesteamp required for the secret key 
        authentication
    '''

    def calcTimeStamp(self):
        # creates a timestamp to the millisecond
        return str(round(time.time() * 1000))





    '''
        This method updates an account
    '''

    def updateAccount(self, post_data=None):
        if not post_data:
            print("You need to pass in an update object")
            return

        params = {
            "timestamp": self.calcTimeStamp()
            # If you are masquerading (acting on behalf) of your subaccount
            # enter your account_id associated with your business account
            # You could add that field in when passing data into the method
            # "masqueradeAs": "ENTER ACCOUNT ID HERE"
        }
        url = WyreApi.API_URL + WyreApi.API_VER3 + WyreApi.API_ACCOUNT_PATH + \
            "?" + urllib.parse.urlencode(params, encoding='utf-8')
        headers = {
            'X-API-Key': WyreApi.API_KEY,
            'X-API-Signature': self.calc_auth_sig_hash(url + json.dumps(post_data))
        }
        response = requests.post(url, headers=headers, json=post_data)
        if response.status_code == 200:
            return json.loads(response.text)
        else:
            print(response)

            
            

if __name__ == "__main__":
    #=========== Initializes a Wyre Obj ============= #
    account = WyreApi()

    #======== Updating account with payment method ==== #
    # You can add/subtract any fields you'd like to update an account
    # https://docs.sendwyre.com/docs/account-resource#section-field-ids
    updateObj = {
        "profileFields": [{
            "fieldId": "individualLegalName",
            "value": "Johnny Quest"
        }, {
            "fieldId": "individualCellphoneNumber",
            "value": "+1 715-111-2222"
        }, {
            "fieldId": "individualEmail",
            "value": "lol@bananaphone.com"
        }, {
            "fieldId": "individualDateOfBirth",
            "value": "1990-09-24"
        }, {
            "fieldId": "individualResidenceAddress",
            "value": {
                "street1": "1 Market St",
                "street2": "Suite 420",
                "city": "San Francisco",
                "state": "CA",
                "postalCode": "94105",
                "country": "US"
            }
        }
        ]
    }

    update = account.updateAccount(updateObj)
    # Prints the server response
    if update:
      print(update)
```

{% endtab %}

{% tab title="cURL" %}

```
################### Update a Wyre Account ###################
# In this example below, I'm using the test env. When you are ready, use the production url: https://api.sendwyre.com

# Feel free to input your fields to update an account. 

curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR-BEARER-TOKEN" \
-d '{"profileFields": [\
{"fieldId": "individualLegalName","value": "Johnny Quest"}, \
{"fieldId": "individualCellphoneNumber","value": "+1 715-111-2222"}, \
{"fieldId": "individualEmail","value": "lol@bananaphone.com"}, \
{"fieldId": "individualDateOfBirth","value": "1990-09-24"}, \
{"fieldId": "individualResidenceAddress","value": ] \
{"street1": "1 Market St",\
"street2": "Suite 420", \
"city": "San Francisco", \
"state": "CA", \
"postalCode": "94105", \
 "country": "US"}}]}' \
https://api.testwyre.com/v3/accounts/your_account_id
#Ex: https://api.testwyre.com/v3/accounts/AC-U4BWHGZDG6W
Result Format
 200 OK
{
  "id" : "AC-U4BWHGZDG6W",
  "status" : "PENDING",
  "type" : "INDIVIDUAL",
  "country" : "US",
  "createdAt" : 1541789972000,
  "depositAddresses" : {
    "ETH" : "0x98B031783d0efb1E65C4072C6576BaCa0736A912",
    "BTC" : "14CriXWTRoJmQdBzdikw6tEmSuwxMozWWq"
  },
  "totalBalances" : { 
    "BTC" : 1.0000000,
    "ETH" : 0.1000000000000000000
  },
  "availableBalances" : { 
    "BTC" : 1.0000000,
    "ETH" : 0.1000000000000000000
  },
  "profileData" : [ {
    "fieldId" : "individualCellphoneNumber",
    "fieldType" : "CELLPHONE",
    "value" : null,
    "note" : "Must be verified by user.",
    "status" : "OPEN"
  }, {
    "fieldId" : "individualEmail",
    "fieldType" : "EMAIL",
    "value" : "johnnyquest22@yolo.com",
    "note" : "Must be verified by user.",
    "status" : "OPEN"
  }, {
    "fieldId" : "individualLegalName",
    "fieldType" : "STRING",
    "value" : "Johnny Quest",
    "note" : null,
    "status" : "PENDING"
  }, {
    "fieldId" : "individualDateOfBirth",
    "fieldType" : "DATE",
    "value" : null,
    "note" : null,
    "status" : "OPEN"
  }, {
    "fieldId" : "individualSsn",
    "fieldType" : "STRING",
    "value" : null,
    "note" : null,
    "status" : "NULL"
  }, {
    "fieldId" : "individualResidenceAddress",
    "fieldType" : "ADDRESS",
    "value" : {
        "street1": "1 Market St",
        "street2": "Suite 402",
        "city": "San Francisco",
        "state": "CA",
        "postalCode": "94105",
        "country": "US"
    },
    "note" : null,
    "status" : "PENDING"
  }, {
    "fieldId" : "individualGovernmentId",
    "fieldType" : "DOCUMENT",
    "value" : [],
    "note" : null,
    "status" : "OPEN"
  }, {
    "fieldId" : "individualSourceOfFunds",
    "fieldType" : "PAYMENT_METHOD",
    "value" : null,
    "note" : "Payment method not yet submitted",
    "status" : "OPEN"
  } ]
}
```

{% endtab %}
{% endtabs %}
